From fd908349444ed64b5f915af71f0289415afb7795 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 20 Jan 2019 13:00:20 +0000 Subject: [PATCH] issue #408: fix test fallout. --- mitogen/master.py | 11 +++++------ mitogen/parent.py | 9 +++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mitogen/master.py b/mitogen/master.py index be417a5f..28d3fa9d 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -145,10 +145,9 @@ LOAD_CONST = dis.opname.index('LOAD_CONST') IMPORT_NAME = dis.opname.index('IMPORT_NAME') -def _getarg(c): - if c < dis.HAVE_ARGUMENT: - return nextb() - return nextb() | (nextb() << 8) +def _getarg(nextb, c): + if c > dis.HAVE_ARGUMENT: + return nextb() | (nextb() << 8) if sys.version_info < (3, 0): @@ -156,13 +155,13 @@ if sys.version_info < (3, 0): # Yield `(op, oparg)` tuples from the code object `co`. ordit = imap(ord, co.co_code) nextb = ordit.next - return ((c, _getarg(c)) for c in ordit) + return ((c, _getarg(nextb, c)) for c in ordit) elif sys.version_info < (3, 6): def iter_opcodes(co): # Yield `(op, oparg)` tuples from the code object `co`. ordit = iter(co.co_code) nextb = ordit.__next__ - return ((c, _getarg(c)) for c in ordit) + return ((c, _getarg(nextb, c)) for c in ordit) else: def iter_opcodes(co): # Yield `(op, oparg)` tuples from the code object `co`. diff --git a/mitogen/parent.py b/mitogen/parent.py index 4731c711..e247b7fb 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -508,6 +508,7 @@ def write_all(fd, s, deadline=None): class IteratingRead(object): def __init__(self, fds, deadline=None): self.deadline = deadline + self.timeout = None self.poller = PREFERRED_POLLER() for fd in fds: self.poller.start_receive(fd) @@ -524,11 +525,11 @@ class IteratingRead(object): def next(self): while self.poller.readers: if self.deadline is not None: - timeout = max(0, self.deadline - time.time()) - if timeout == 0: + self.timeout = max(0, self.deadline - time.time()) + if self.timeout == 0: break - for fd in self.poller.poll(timeout): + for fd in self.poller.poll(self.timeout): s, disconnected = mitogen.core.io_op(os.read, fd, 4096) if disconnected or not s: IOLOG.debug('iter_read(%r) -> disconnected', fd) @@ -538,7 +539,7 @@ class IteratingRead(object): self.bits.append(s) return s - if not poller.readers: + if not self.poller.readers: raise EofError(u'EOF on stream; last 300 bytes received: %r' % (b('').join(self.bits)[-300:].decode('latin1'),))