Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle EINTR in Stream.poll() #76

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rpyc/core/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,24 @@ def poll(self, timeout):
"""indicates whether the stream has data to read (within *timeout*
seconds)"""
try:
rl, _, _ = select([self], [], [], timeout)
rl, _, _ = self._select([self], [], [], timeout)
except ValueError:
# i got this once: "ValueError: file descriptor cannot be a negative integer (-1)"
# let's translate it to select.error
ex = sys.exc_info()[1]
raise select_error(str(ex))
return bool(rl)
def _select(self, reads, writes, exc, timeout):
end_time = None if timeout is None else time.time() + timeout
while True:
try:
return select(reads, writes, exc, timeout)
except socket.error:
ex = sys.exc_info()[1]
if get_exc_errno(ex) != errno.EINTR:
raise
if end_time is not None:
timeout = max(0, end_time - time.time())
def read(self, count):
"""reads **exactly** *count* bytes, or raise EOFError

Expand Down