issue #408: fix test fallout.

issue510
David Wilson 6 years ago
parent b7add60097
commit fd90834944

@ -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`.

@ -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'),))

Loading…
Cancel
Save