diff --git a/portal/client_socket.py b/portal/client_socket.py index 94812a6..35d7130 100644 --- a/portal/client_socket.py +++ b/portal/client_socket.py @@ -190,7 +190,6 @@ def _connect(self): port = int(port) addr = (host, port, 0, 0) if self.options.ipv6 else (host, port) sock = self._create() - start = time.time() error = None try: sock.settimeout(10) diff --git a/portal/server.py b/portal/server.py index b64aa85..45a977c 100644 --- a/portal/server.py +++ b/portal/server.py @@ -124,14 +124,16 @@ def _loop(self): data = job.result() if job.postfn: data, info = data - else: - job.active.release() + del info data = packlib.pack(data) status = int(0).to_bytes(8, 'little', signed=False) self.socket.send(job.addr, job.reqnum, status, *data) self.metrics['send'] += 1 except Exception as e: self._error(job.addr, job.reqnum, 4, f'Error in server method: {e}') + finally: + if not job.postfn: + job.active.release() if completed: while self.postfn_inp and self.postfn_inp[0].done(): job = self.postfn_inp.popleft() diff --git a/portal/server_socket.py b/portal/server_socket.py index 8b21b11..2bf8293 100644 --- a/portal/server_socket.py +++ b/portal/server_socket.py @@ -52,7 +52,7 @@ def __init__(self, port, name='Server', **kwargs): self._log(f'Binding to {self.addr[0]}:{self.addr[1]}') self.sock.bind(self.addr) self.sock.setblocking(False) - self.sock.listen() + self.sock.listen(8192) self.sel = selectors.DefaultSelector() self.sel.register(self.sock, selectors.EVENT_READ, data=None) self._log(f'Listening at {self.addr[0]}:{self.addr[1]}')