Passing asyncio loop by argument or using default asyncio loop

后端 未结 1 1314
渐次进展
渐次进展 2020-12-24 13:23

I\'m using asyncio in my application and i\'m a litte bit confused about passing the event loop as argument.

You\'ve three possibilities when writing a func

相关标签:
1条回答
  • 2020-12-24 14:17

    A good (as in praised by Guido van Rossum) blog post discussing this is Some thoughts on asynchronous API design in a post-async/await world. With a follow up discussion from python core developers here.

    TLDR;

    If you're only using one event loop, it doesn't matter.

    If you're managing multiple loops, and have python >= 3.6 it mostly doesn't matter: Do not use argument and use asyncio.get_event_loop() where needed, it will give you the correct loop.

    0 讨论(0)
提交回复
热议问题