def wait(self, timeout=None):
"""Must be used with 'yield' as 'yield event.wait()' .
"""
if self._flag:
raise StopIteration(True)
if not self._scheduler:
self._scheduler = Pycos.scheduler()
task = Pycos.cur_task(self._scheduler)
if timeout is not None:
if timeout <= 0:
raise StopIteration(False)
self._waitlist.append(task)
if (yield task._await_(timeout)) is None:
try:
self._waitlist.remove(task)
except ValueError:
pass
raise StopIteration(False)
else:
raise StopIteration(True)
评论列表
文章目录