Skip to content

Commit

Permalink
Fixed usage of system-level poll().
Browse files Browse the repository at this point in the history
The bug in compat.py was unveiled after fixing bug tomerfiliba-org#182 and observing spinning processes.
After that, the poll() call in server.py became too slow (1s instead of 1ms),
leading to timeouts. The new value allows for not spinning too fast yet
reacting quickly to new incoming connections.
  • Loading branch information
glpatcern committed Mar 31, 2016
1 parent 843ba58 commit 783ca13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion rpyc/lib/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def register(self, fd, mode):
if "e" in mode:
flags |= select_module.POLLERR
if "h" in mode:
# POLLRDHUP is a linux only extension, not know to python, but nevertheless
# POLLRDHUP is a linux only extension, not known to python, but nevertheless
# used and thus needed in the flags
POLLRDHUP = 0x2000
flags |= select_module.POLLHUP | select_module.POLLNVAL | POLLRDHUP
Expand All @@ -101,6 +101,9 @@ def register(self, fd, mode):
def unregister(self, fd):
self._poll.unregister(fd)
def poll(self, timeout = None):
if timeout:
# the real poll takes milliseconds while we have seconds here
timeout = 1000*timeout
events = self._poll.poll(timeout)
processed = []
for fd, evt in events:
Expand Down
4 changes: 2 additions & 2 deletions rpyc/utils/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ def _poll_inactive_clients(self):
Check whether inactive clients have become active'''
while self.active:
try:
# the actual poll, with a timeout of 1s so that we can exit in case
# the actual poll, with a timeout of 0.1s so that we can exit in case
# we re not active anymore
active_clients = self.poll_object.poll(1)
active_clients = self.poll_object.poll(0.1)
# for each client that became active, put them in the active queue
self._handle_poll_result(active_clients)
except Exception:
Expand Down

0 comments on commit 783ca13

Please sign in to comment.