[Python-modules-commits] [python-async-timeout] 01/04: Import python-async-timeout_1.2.1.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Tue Jun 20 17:44:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository python-async-timeout.
commit a409c2cd0ff5c02afed9fb9a0462ea420e28390b
Author: Piotr Ożarowski <piotr at debian.org>
Date: Tue Jun 20 19:42:03 2017 +0200
Import python-async-timeout_1.2.1.orig.tar.gz
---
CHANGES.rst | 14 ++++++++++++++
PKG-INFO | 22 +++++++++++++++++++---
README.rst | 4 ++--
async_timeout.egg-info/PKG-INFO | 22 +++++++++++++++++++---
async_timeout/__init__.py | 23 +++++++++++++++++------
setup.cfg | 1 -
setup.py | 9 ++++++---
tests/test_timeout.py | 15 +++++++++++++++
8 files changed, 92 insertions(+), 18 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 312a7f4..2d495f5 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,20 @@
CHANGES
=======
+1.2.1 (2017-05-02)
+------------------
+
+* Support unpublished event loop's "current_task" api.
+
+
+1.2.0 (2017-03-11)
+------------------
+
+* Extra check on context manager exit
+
+* 0 is no-op timeout
+
+
1.1.0 (2016-10-20)
------------------
diff --git a/PKG-INFO b/PKG-INFO
index 6d82f62..031f127 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: async-timeout
-Version: 1.1.0
+Version: 1.2.1
Summary: Timeout context manager for asyncio programs
Home-page: https://github.com/aio-libs/async_timeout/
Author: Andrew Svetlov
Author-email: andrew.svetlov at gmail.com
License: Apache 2
-Description: async_timeout
+Description: async-timeout
=============
asyncio-compatible timeout context manager.
@@ -40,7 +40,7 @@ Description: async_timeout
::
- $ pip install async_timeout
+ $ pip install async-timeout
The library is Python 3 only!
@@ -57,6 +57,20 @@ Description: async_timeout
CHANGES
=======
+ 1.2.1 (2017-05-02)
+ ------------------
+
+ * Support unpublished event loop's "current_task" api.
+
+
+ 1.2.0 (2017-03-11)
+ ------------------
+
+ * Extra check on context manager exit
+
+ * 0 is no-op timeout
+
+
1.1.0 (2016-10-20)
------------------
@@ -74,4 +88,6 @@ Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Framework :: AsyncIO
diff --git a/README.rst b/README.rst
index 02ea803..0bf302b 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-async_timeout
+async-timeout
=============
asyncio-compatible timeout context manager.
@@ -32,7 +32,7 @@ Installation
::
- $ pip install async_timeout
+ $ pip install async-timeout
The library is Python 3 only!
diff --git a/async_timeout.egg-info/PKG-INFO b/async_timeout.egg-info/PKG-INFO
index 6d82f62..031f127 100644
--- a/async_timeout.egg-info/PKG-INFO
+++ b/async_timeout.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: async-timeout
-Version: 1.1.0
+Version: 1.2.1
Summary: Timeout context manager for asyncio programs
Home-page: https://github.com/aio-libs/async_timeout/
Author: Andrew Svetlov
Author-email: andrew.svetlov at gmail.com
License: Apache 2
-Description: async_timeout
+Description: async-timeout
=============
asyncio-compatible timeout context manager.
@@ -40,7 +40,7 @@ Description: async_timeout
::
- $ pip install async_timeout
+ $ pip install async-timeout
The library is Python 3 only!
@@ -57,6 +57,20 @@ Description: async_timeout
CHANGES
=======
+ 1.2.1 (2017-05-02)
+ ------------------
+
+ * Support unpublished event loop's "current_task" api.
+
+
+ 1.2.0 (2017-03-11)
+ ------------------
+
+ * Extra check on context manager exit
+
+ * 0 is no-op timeout
+
+
1.1.0 (2016-10-20)
------------------
@@ -74,4 +88,6 @@ Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Framework :: AsyncIO
diff --git a/async_timeout/__init__.py b/async_timeout/__init__.py
index df9143f..ee0817a 100644
--- a/async_timeout/__init__.py
+++ b/async_timeout/__init__.py
@@ -1,7 +1,7 @@
import asyncio
-__version__ = '1.1.0'
+__version__ = '1.2.1'
class timeout:
@@ -19,6 +19,8 @@ class timeout:
loop - asyncio compatible event loop
"""
def __init__(self, timeout, *, loop=None):
+ if timeout is not None and timeout == 0:
+ timeout = None
self._timeout = timeout
if loop is None:
loop = asyncio.get_event_loop()
@@ -28,11 +30,11 @@ class timeout:
self._cancel_handler = None
def __enter__(self):
- self._task = asyncio.Task.current_task(loop=self._loop)
- if self._task is None:
- raise RuntimeError('Timeout context manager should be used '
- 'inside a task')
if self._timeout is not None:
+ self._task = current_task(self._loop)
+ if self._task is None:
+ raise RuntimeError('Timeout context manager should be used '
+ 'inside a task')
self._cancel_handler = self._loop.call_later(
self._timeout, self._cancel_task)
return self
@@ -42,10 +44,19 @@ class timeout:
self._cancel_handler = None
self._task = None
raise asyncio.TimeoutError from None
- if self._timeout is not None:
+ if self._timeout is not None and self._cancel_handler is not None:
self._cancel_handler.cancel()
self._cancel_handler = None
self._task = None
def _cancel_task(self):
self._cancelled = self._task.cancel()
+
+
+def current_task(loop):
+ task = asyncio.Task.current_task(loop=loop)
+ if task is None:
+ if hasattr(loop, 'current_task'):
+ task = loop.current_task()
+
+ return task
diff --git a/setup.cfg b/setup.cfg
index 4882edf..e4eba0b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,5 +4,4 @@ test = pytest
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff --git a/setup.py b/setup.py
index 4a736d6..1dbdffa 100644
--- a/setup.py
+++ b/setup.py
@@ -31,12 +31,15 @@ setup(name='async-timeout',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
- 'Topic :: Internet :: WWW/HTTP'],
+ 'Programming Language :: Python :: 3.6',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: AsyncIO',
+ ],
author='Andrew Svetlov',
author_email='andrew.svetlov at gmail.com',
url='https://github.com/aio-libs/async_timeout/',
license='Apache 2',
packages=['async_timeout'],
- setup_requires=['pytest-runner'],
- tests_require=['pytest', 'pytest_aiohttp'],
+ setup_requires=[],
+ tests_require=['pytest', 'pytest_aiohttp', 'pytest-runner'],
include_package_data=False)
diff --git a/tests/test_timeout.py b/tests/test_timeout.py
index 9c7dc40..3f7937b 100644
--- a/tests/test_timeout.py
+++ b/tests/test_timeout.py
@@ -81,6 +81,21 @@ def test_timeout_disable(loop):
@asyncio.coroutine
+def test_timeout_disable_zero(loop):
+ @asyncio.coroutine
+ def long_running_task():
+ yield from asyncio.sleep(0.1, loop=loop)
+ return 'done'
+
+ t0 = loop.time()
+ with timeout(0, loop=loop):
+ resp = yield from long_running_task()
+ assert resp == 'done'
+ dt = loop.time() - t0
+ assert 0.09 < dt < 0.13, dt
+
+
+ at asyncio.coroutine
def test_timeout_not_relevant_exception(loop):
yield from asyncio.sleep(0, loop=loop)
with pytest.raises(KeyError):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-async-timeout.git
More information about the Python-modules-commits
mailing list