Code: Select all
async def async_main():
# Everything here can use asyncio.create_task():
o = ObjectThatMustBeKeptReferenced()
create_tasks_and_register_callbacks(o)
# Wait forever, ugly:
while True:
await asyncio.sleep(10000)
asyncio.run(async_main())
Code: Select all
def main():
loop = asyncio.get_event_loop()
# Everything here can use asyncio.create_task():
o = ObjectThatMustBeKeptReferenced()
create_tasks_and_register_callbacks(o)
# Wait forever, pretty:
loop.run_forever()
main()
Was ist Python, eine Möglichkeit, für immer in der asyncio-Ereignisschleife zu schlafen?
Mobile version