跳转到主要内容

为asyncio模块进行猴子补丁以实现预期行为

项目描述

asyncio_monkey
==============

:info: 为asyncio模块进行猴子补丁以实现预期行为

.. image:: https://img.shields.io/travis/wikibusiness/asyncio_monkey.svg
:target: https://travis-ci.org/wikibusiness/asyncio_monkey

.. image:: https://img.shields.io/pypi/v/asyncio_monkey.svg
:target: https://pypi.python.org/pypi/asyncio_monkey

安装
------------

.. code-block:: shell

pip install asyncio_monkey

用法
-----

.. code-block:: python

# 在任何导入asyncio语句之前执行,每个项目一次
# 最好放在您的应用程序的__init__.py中
from asyncio_monkey import patch_all # noqa isort:skip
patch_all()

或调用所需的函数

.. code-block:: python

# 在任何导入asyncio语句之前执行,每个项目一次
# 最好放在您的应用程序的__init__.py中
import asyncio_monkey # noqa isort:skip

asyncio_monkey.patch_gather()
asyncio_monkey.patch_log_destroy_pending()
asyncio_monkey.patch_get_event_loop()
asyncio_monkey.patch_lock()

功能
--------

- 如果任何任务失败,则取消挂起的任务 `gather`,`source <https://bugs.python.org/issue31452>`_

- 禁用 `get_event_loop` 返回当前运行的循环,即使 `MainThread` 循环为 `None`,`docs <https://docs.pythonlang.cn/3/library/asyncio-eventloops.html#asyncio.get_event_loop>`_ ,`source <https://bugs.python.org/issue28613>`_

- 禁用 `asyncio.gather` 内部静默销毁未来对象 `source <https://github.com/python/cpython/blob/3dc7c52a9f4fb83be3e26e31e2c7cd9dc1cb41a2/Lib/asyncio/tasks.py#L600>`_

- 防止取消后 `asyncio.Lock` 死锁 `source <http://bugs.python.org/issue27585>`_

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

asyncio_monkey-0.1.1.tar.gz (4.0 kB 查看哈希)

上传时间

支持者