From 98cd813da50bcd5b5e21c9d6276c9fb014b3c502 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Thu, 31 Mar 2016 10:07:02 +0200 Subject: [PATCH] Fixed usage of system-level poll(). The bug in compat.py was unveiled after fixing bug #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. --- rpyc/lib/compat.py | 5 ++++- rpyc/utils/server.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rpyc/lib/compat.py b/rpyc/lib/compat.py index e5d55dfa..76a8dc16 100644 --- a/rpyc/lib/compat.py +++ b/rpyc/lib/compat.py @@ -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 @@ -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: diff --git a/rpyc/utils/server.py b/rpyc/utils/server.py index 23cb0405..47f0053d 100644 --- a/rpyc/utils/server.py +++ b/rpyc/utils/server.py @@ -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: