找出代码在哪个异步库下运行
sniffio的Python项目详细描述
sniffio:找出代码在哪个异步库下运行
你在写一个图书馆。你决定要有雄心壮志,支持 多个异步I/O包,比如Trio,和asyncio,还有……您已经 写了一堆聪明的代码来处理所有的差异。但是… 你怎么知道要运行哪段聪明的代码?
这是一个很小的包裹,它的唯一目的是让你发现 运行代码的异步库。
- 文档:https://sniffio.readthedocs.io
- bug跟踪器和源代码:https://github.com/python-trio/sniffio
- 许可证:mit或apache许可证2.0,您可以选择
- 投稿指南:https://trio.readthedocs.io/en/latest/contributing.html
- 行为准则:请投稿人遵守我们的code of conduct 在所有项目空间中。
这个图书馆由Trio项目维护,为 作为一个整体的异步python社区。
快速启动
fromsniffioimportcurrent_async_libraryimporttrioimportasyncioasyncdefprint_library():library=current_async_library()print("This is:",library)# Prints "This is trio"trio.run(print_library)# Prints "This is asyncio"asyncio.run(print_library())
有关更多详细信息,包括如何向新的异步库添加支持, please peruse our fine manual。