File sending fix (#61)

* Changed sending buffering

* Connected config to buffer size in clients

* Update data logging for file transmit

* Fix logging when receive data

Co-authored-by: Arthur Golubtsov <goldartt@gmail.com>
This commit is contained in:
artem30801
2019-12-26 18:23:10 +03:00
committed by Arthur Golubtsov
parent b253a0cf8e
commit 853cc0d3fa
4 changed files with 13 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
port = 25000
broadcast_port = 8181
host = 192.168.1.101
buffer_size = 1024
buffer_size = 10000
[VISUAL_POSE_WATCHDOG]
timeout = 1.0
@@ -64,3 +64,4 @@ animation_file = animation.csv
use_ntp = False
host = ntp1.stratum2.ru
port = 123

View File

@@ -180,6 +180,7 @@ class Server(messaging.Singleton):
if not any([client_addr == addr[0] for client_addr in Client.clients.keys()]):
client = Client(addr[0])
client.buffer_size = self.BUFFER_SIZE
logging.info("New client")
else:
client = Client.clients[addr[0]]
@@ -336,7 +337,7 @@ class Client(messaging.ConnectionManager):
@requires_connect
def _send(self, data):
super(Client, self)._send(data)
logging.debug("Queued data to send: {}".format(data))
logging.debug("Queued data to send (first 256 bytes): {}".format(data[:256]))
def send_config_options(self, *options: ConfigOption, reload_config=True):
logging.info("Sending config options: {} to {}".format(options, self.addr))

View File

@@ -1,6 +1,6 @@
[SERVER]
port = 25000
buffer_size = 1024
buffer_size = 10000
remove_disconnected = False
[CHECKS]

View File

@@ -227,7 +227,7 @@ class ConnectionManager(object):
self._request_lock = threading.Lock()
self._close_lock = threading.Lock()
self.BUFFER_SIZE = 1024
self.buffer_size = 1024
self.resume_queue = False
self.resend_requests = True
@@ -333,14 +333,14 @@ class ConnectionManager(object):
def _read(self):
try:
data = self.socket.recv(self.BUFFER_SIZE)
data = self.socket.recv(self.buffer_size)
except io.BlockingIOError:
# Resource temporarily unavailable (errno EWOULDBLOCK)
pass
else:
if data:
self._recv_buffer += data
logger.debug("Received {} from {}".format(data, self.addr))
logger.debug("Received {} bytes from {}".format(len(data), self.addr))
else:
logger.warning("Connection to {} lost!".format(self.addr))
@@ -426,7 +426,7 @@ class ConnectionManager(object):
def _write(self):
try:
sent = self.socket.send(self._send_buffer)
sent = self.socket.send(self._send_buffer[:self.buffer_size])
except io.BlockingIOError:
# Resource temporarily unavailable (errno EWOULDBLOCK)
pass
@@ -436,8 +436,10 @@ class ConnectionManager(object):
raise error
else:
logger.debug("Sent {} to {}".format(self._send_buffer[:sent], self.addr))
self._send_buffer = self._send_buffer[sent:]
left = len(self._send_buffer)
logger.debug("Sent message to {}: sent {} bytes, {} bytes left.".format(self.addr, sent, left))#, self._send_buffer[:sent],))
def _send(self, data):
with self._send_lock: