Message305662
If you await a Future with another loop than a loop at instance creation (this is trivial to do accidentally when using threads), asyncio raises a RuntimeError. But if you use another part of the Future API, such as add_done_callback(), the situation isn't detected.
For example, this snippet will run indefinitely:
import asyncio
import threading
fut = asyncio.Future()
async def coro(loop):
fut.add_done_callback(lambda _: loop.stop())
loop.call_later(1, fut.set_result, None)
while True:
await asyncio.sleep(100000)
def run():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(coro(loop))
loop.close()
t = threading.Thread(target=run)
t.start()
t.join() |
|
Date |
User |
Action |
Args |
2017-11-06 17:24:09 | pitrou | set | recipients:
+ pitrou, vstinner, giampaolo.rodola, yselivanov |
2017-11-06 17:24:09 | pitrou | set | messageid: <1509989049.58.0.213398074469.issue31960@psf.upfronthosting.co.za> |
2017-11-06 17:24:09 | pitrou | link | issue31960 messages |
2017-11-06 17:24:09 | pitrou | create | |
|