uasyncio: wait: Add workaround against heap alloc on empty iteration.

"for a in ():" unconditionally allocates heap so far, per
https://github.com/micropython/micropython/issues/2716 . So, test for
empty result before iterating over it.
pull/62/merge
Paul Sokolovsky 2016-12-28 10:25:31 +03:00
rodzic 9d5919dd1c
commit f29be360c0
1 zmienionych plików z 11 dodań i 8 usunięć

Wyświetl plik

@ -60,14 +60,17 @@ class EpollEventLoop(EventLoop):
else: else:
res = self.poller.poll(delay, 1) res = self.poller.poll(delay, 1)
#log.debug("epoll result: %s", res) #log.debug("epoll result: %s", res)
for fd, ev in res: # Remove "if res" workaround after
cb = self.objmap[fd] # https://github.com/micropython/micropython/issues/2716 fixed.
if __debug__: if res:
log.debug("Calling IO callback: %r", cb) for fd, ev in res:
if isinstance(cb, tuple): cb = self.objmap[fd]
cb[0](*cb[1]) if __debug__:
else: log.debug("Calling IO callback: %r", cb)
self.call_soon(cb) if isinstance(cb, tuple):
cb[0](*cb[1])
else:
self.call_soon(cb)
class StreamReader: class StreamReader: