New Upstream Release - python-nest-asyncio
Ready changes
Summary
Merged new upstream version: 1.5.7 (was: 1.5.6).
Resulting package
Built on 2023-08-11T01:27 (took 5m4s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases python3-nest-asyncio
Lintian Result
Diff
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..e920253
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: erdewit
+custom: www.paypal.me/erdewit
\ No newline at end of file
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..ae530dc
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,47 @@
+name: nest_asyncio
+
+on: [ push, pull_request, workflow_dispatch ]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy-3.9 ]
+ exclude:
+ - os: ubuntu-latest
+ python-version: 3.5
+ - os: ubuntu-latest
+ python-version: 3.6
+ include:
+ - os: ubuntu-20.04
+ python-version: 3.5
+ - os: ubuntu-20.04
+ python-version: 3.6
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install flake8 mypy .
+
+ - name: Flake8 static code analysis
+ run:
+ flake8 nest_asyncio.py
+
+ - name: MyPy static code analysis
+ run: |
+ mypy nest_asyncio.py
+
+ - name: Testsuite
+ run: |
+ python tests/nest_test.py
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b19a8d4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,107 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# dotenv
+.env
+
+# virtualenv
+.venv
+venv/
+ENV/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+
+.vscode
+.project
+.pydevproject
+.settings/
+.idea
diff --git a/PKG-INFO b/PKG-INFO
index eb73557..da5e0a6 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,13 +1,12 @@
Metadata-Version: 2.1
Name: nest_asyncio
-Version: 1.5.4
+Version: 1.5.7
Summary: Patch asyncio to allow nested event loops
Home-page: https://github.com/erdewit/nest_asyncio
Author: Ewald R. de Wit
Author-email: ewald.de.wit@gmail.com
License: BSD
Keywords: asyncio,nested,eventloop
-Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
@@ -17,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Framework :: AsyncIO
Requires-Python: >=3.5
@@ -84,5 +84,3 @@ generally can't be patched.
:alt: Number of downloads
:target: https://pepy.tech/project/nest-asyncio
-
-
diff --git a/debian/changelog b/debian/changelog
index 1212910..1ddddd1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-nest-asyncio (1.5.7-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Fri, 11 Aug 2023 01:22:42 -0000
+
python-nest-asyncio (1.5.4-1) unstable; urgency=medium
[ Diego M. Rodriguez ]
diff --git a/dist.sh b/dist.sh
new file mode 100755
index 0000000..f5b4001
--- /dev/null
+++ b/dist.sh
@@ -0,0 +1,4 @@
+rm -rf dist build
+python3 setup.py sdist bdist_wheel
+python3 -m twine upload dist/*
+rm -rf dist build *.egg-info
diff --git a/nest_asyncio.egg-info/PKG-INFO b/nest_asyncio.egg-info/PKG-INFO
index 2a24325..f1036cf 100644
--- a/nest_asyncio.egg-info/PKG-INFO
+++ b/nest_asyncio.egg-info/PKG-INFO
@@ -1,13 +1,12 @@
Metadata-Version: 2.1
Name: nest-asyncio
-Version: 1.5.4
+Version: 1.5.7
Summary: Patch asyncio to allow nested event loops
Home-page: https://github.com/erdewit/nest_asyncio
Author: Ewald R. de Wit
Author-email: ewald.de.wit@gmail.com
License: BSD
Keywords: asyncio,nested,eventloop
-Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
@@ -17,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Framework :: AsyncIO
Requires-Python: >=3.5
@@ -84,5 +84,3 @@ generally can't be patched.
:alt: Number of downloads
:target: https://pepy.tech/project/nest-asyncio
-
-
diff --git a/nest_asyncio.egg-info/SOURCES.txt b/nest_asyncio.egg-info/SOURCES.txt
index c8a0e87..db9d6ae 100644
--- a/nest_asyncio.egg-info/SOURCES.txt
+++ b/nest_asyncio.egg-info/SOURCES.txt
@@ -1,10 +1,14 @@
+.gitignore
LICENSE
MANIFEST.in
README.rst
+dist.sh
nest_asyncio.py
pyproject.toml
setup.cfg
setup.py
+.github/FUNDING.yml
+.github/workflows/test.yml
nest_asyncio.egg-info/PKG-INFO
nest_asyncio.egg-info/SOURCES.txt
nest_asyncio.egg-info/dependency_links.txt
diff --git a/nest_asyncio.py b/nest_asyncio.py
index 4b0fde6..4459699 100644
--- a/nest_asyncio.py
+++ b/nest_asyncio.py
@@ -1,3 +1,5 @@
+"""Patch asyncio to allow nested event loops."""
+
import asyncio
import asyncio.events as events
import os
@@ -9,29 +11,20 @@ from heapq import heappop
def apply(loop=None):
"""Patch asyncio to make its event loop reentrant."""
- loop = loop or asyncio.get_event_loop()
- if not isinstance(loop, asyncio.BaseEventLoop):
- raise ValueError('Can\'t patch loop of type %s' % type(loop))
- if getattr(loop, '_nest_patched', None):
- # already patched
- return
_patch_asyncio()
- _patch_loop(loop)
+ _patch_policy()
_patch_task()
_patch_tornado()
+ loop = loop or asyncio.get_event_loop()
+ _patch_loop(loop)
+
def _patch_asyncio():
- """
- Patch asyncio module to use pure Python tasks and futures,
- use module level _current_tasks, all_tasks and patch run method.
- """
+ """Patch asyncio module to use pure Python tasks and futures."""
+
def run(main, *, debug=False):
- loop = events._get_running_loop()
- if not loop:
- loop = events.new_event_loop()
- events.set_event_loop(loop)
- _patch_loop(loop)
+ loop = asyncio.get_event_loop()
loop.set_debug(debug)
task = asyncio.ensure_future(main)
try:
@@ -42,6 +35,15 @@ def _patch_asyncio():
with suppress(asyncio.CancelledError):
loop.run_until_complete(task)
+ def _get_event_loop(stacklevel=3):
+ loop = events._get_running_loop()
+ if loop is None:
+ loop = events.get_event_loop_policy().get_event_loop()
+ return loop
+
+ # Use module level _current_tasks, all_tasks and patch run method.
+ if hasattr(asyncio, '_nest_patched'):
+ return
if sys.version_info >= (3, 6, 0):
asyncio.Task = asyncio.tasks._CTask = asyncio.tasks.Task = \
asyncio.tasks._PyTask
@@ -50,9 +52,25 @@ def _patch_asyncio():
if sys.version_info < (3, 7, 0):
asyncio.tasks._current_tasks = asyncio.tasks.Task._current_tasks
asyncio.all_tasks = asyncio.tasks.Task.all_tasks
- if not hasattr(asyncio, '_run_orig'):
- asyncio._run_orig = getattr(asyncio, 'run', None)
- asyncio.run = run
+ if sys.version_info >= (3, 9, 0):
+ events._get_event_loop = events.get_event_loop = \
+ asyncio.get_event_loop = _get_event_loop
+ asyncio.run = run
+ asyncio._nest_patched = True
+
+
+def _patch_policy():
+ """Patch the policy to always return a patched loop."""
+
+ def get_event_loop(self):
+ if self._local._loop is None:
+ loop = self.new_event_loop()
+ _patch_loop(loop)
+ self.set_event_loop(loop)
+ return self._local._loop
+
+ policy = events.get_event_loop_policy()
+ policy.__class__.get_event_loop = get_event_loop
def _patch_loop(loop):
@@ -160,18 +178,22 @@ def _patch_loop(loop):
"""Do not throw exception if loop is already running."""
pass
+ if hasattr(loop, '_nest_patched'):
+ return
+ if not isinstance(loop, asyncio.BaseEventLoop):
+ raise ValueError('Can\'t patch loop of type %s' % type(loop))
cls = loop.__class__
cls.run_forever = run_forever
cls.run_until_complete = run_until_complete
cls._run_once = _run_once
cls._check_running = _check_running
cls._check_runnung = _check_running # typo in Python 3.7 source
- cls._nest_patched = True
cls._num_runs_pending = 0
cls._is_proactorloop = (
- os.name == 'nt' and issubclass(cls, asyncio.ProactorEventLoop))
+ os.name == 'nt' and issubclass(cls, asyncio.ProactorEventLoop))
if sys.version_info < (3, 7, 0):
cls._set_coroutine_origin_tracking = cls._set_coroutine_wrapper
+ cls._nest_patched = True
def _patch_task():
@@ -188,6 +210,8 @@ def _patch_task():
curr_tasks[task._loop] = curr_task
Task = asyncio.Task
+ if hasattr(Task, '_nest_patched'):
+ return
if sys.version_info >= (3, 7, 0):
def enter_task(loop, task):
@@ -205,15 +229,16 @@ def _patch_task():
curr_tasks = Task._current_tasks
step_orig = Task._step
Task._step = step
+ Task._nest_patched = True
def _patch_tornado():
- """
- If tornado is imported before nest_asyncio, make tornado aware of
- the pure-Python asyncio Future.
- """
- if 'tornado' in sys.modules:
- import tornado.concurrent as tc
- tc.Future = asyncio.Future
- if asyncio.Future not in tc.FUTURES:
- tc.FUTURES += (asyncio.Future,)
+ """
+ If tornado is imported before nest_asyncio, make tornado aware of
+ the pure-Python asyncio Future.
+ """
+ if 'tornado' in sys.modules:
+ import tornado.concurrent as tc # type: ignore
+ tc.Future = asyncio.Future
+ if asyncio.Future not in tc.FUTURES:
+ tc.FUTURES += (asyncio.Future,)
diff --git a/setup.cfg b/setup.cfg
index 0d74adb..40a75fe 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = nest_asyncio
-version = 1.5.4
+version = 1.5.7
author = Ewald R. de Wit
author_email = ewald.de.wit@gmail.com
license = BSD
@@ -20,6 +20,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
+ Programming Language :: Python :: 3.11
Programming Language :: Python :: 3 :: Only
Framework :: AsyncIO
@@ -27,6 +28,9 @@ classifiers =
py_modules = nest_asyncio
python_requires = >=3.5
+[flake8]
+ignore = D205,D400,W503
+
[egg_info]
tag_build =
tag_date = 0
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.7.egg-info/PKG-INFO -rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.7.egg-info/dependency_links.txt -rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.7.egg-info/top_level.txt
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.4.egg-info/PKG-INFO -rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.4.egg-info/dependency_links.txt -rw-r--r-- root/root /usr/lib/python3/dist-packages/nest_asyncio-1.5.4.egg-info/top_level.txt
No differences were encountered in the control files