Compare commits
3 Commits
61a607c20e
...
f365139e9f
| Author | SHA1 | Date | |
|---|---|---|---|
|
f365139e9f
|
|||
|
cc6b650f5c
|
|||
|
faf1f4eeee
|
@@ -7,6 +7,8 @@ import socket
|
||||
import threading
|
||||
import time
|
||||
|
||||
from typing import Any
|
||||
|
||||
from judas_protocol import Category, ControlAction, Message
|
||||
|
||||
from judas_server.backend.client import Client
|
||||
@@ -103,14 +105,11 @@ class BackendServer:
|
||||
|
||||
client.disconnect()
|
||||
|
||||
def _send_outbound(
|
||||
self, sock: socket.socket, client: Client, data: bytes
|
||||
) -> None:
|
||||
def _send_outbound(self, sock: socket.socket, client: Client) -> None:
|
||||
"""Queue data to be sent to a client.
|
||||
|
||||
Args:
|
||||
client (Client): The client to send data to.
|
||||
data (bytes): The data to send.
|
||||
"""
|
||||
self.logger.debug(f"[>] Sending data to {client}: {client.outbound!r}")
|
||||
sent = sock.send(client.outbound)
|
||||
@@ -219,7 +218,7 @@ class BackendServer:
|
||||
|
||||
if mask & selectors.EVENT_WRITE:
|
||||
if client.outbound:
|
||||
self._send_outbound(sock, client, client.outbound)
|
||||
self._send_outbound(sock, client)
|
||||
|
||||
except ConnectionResetError as e:
|
||||
self.logger.error(f"Connection reset by {client}, disconnect: {e}")
|
||||
@@ -243,7 +242,7 @@ class BackendServer:
|
||||
events = self.selector.select(timeout=1)
|
||||
for key, mask in events:
|
||||
if key.data is None:
|
||||
self._accept_connection(key.fileobj)
|
||||
self._accept_connection(key.fileobj) # type: ignore
|
||||
else:
|
||||
self._handle_connection(key, mask)
|
||||
time.sleep(0.001) # prevent 100% CPU usage
|
||||
|
||||
Reference in New Issue
Block a user