Skip to content

Commit

Permalink
Add loop sleep parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
danijar committed Sep 18, 2024
1 parent 933d1b0 commit b54d44c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.4.2'
__version__ = '3.4.3'

import multiprocessing as mp
try:
Expand Down
4 changes: 4 additions & 0 deletions portal/client_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Options:
logging: bool = True
logging_color: str = 'yellow'
connect_wait: float = 0.1
loop_sleep: float = 0.0


class ClientSocket:
Expand Down Expand Up @@ -175,6 +176,9 @@ def _loop(self):
[x() for x in self.callbacks_disc]
continue

if self.options.loop_sleep:
time.sleep(self.options.loop_sleep)

if sock:
sock.close()

Expand Down
4 changes: 4 additions & 0 deletions portal/server_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import queue
import selectors
import socket
import time

from . import buffers
from . import contextlib
Expand Down Expand Up @@ -31,6 +32,7 @@ class Options:
max_send_queue: int = 4096
logging: bool = True
logging_color: str = 'blue'
loop_sleep: float = 0.0


class ServerSocket:
Expand Down Expand Up @@ -127,6 +129,8 @@ def _loop(self):
# The client is gone but we may have buffered messages left to
# read, so we keep the socket open until recv() fails.
pass
if self.options.loop_sleep:
time.sleep(self.options.loop_sleep)
except Exception as e:
self.error = e

Expand Down

0 comments on commit b54d44c

Please sign in to comment.