[Python-modules-commits] [aioredis] 01/03: Import aioredis_0.3.1.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Tue Jun 20 14:06:10 UTC 2017
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository aioredis.
commit 208df42042dadfa7b251e5eb1dbc55810a0b35a9
Author: Piotr Ożarowski <piotr at debian.org>
Date: Tue Jun 20 16:03:54 2017 +0200
Import aioredis_0.3.1.orig.tar.gz
---
CHANGES.txt | 9 +++++++++
PKG-INFO | 11 ++++++++++-
aioredis.egg-info/PKG-INFO | 11 ++++++++++-
aioredis.egg-info/SOURCES.txt | 3 +++
aioredis/__init__.py | 2 +-
aioredis/pubsub.py | 34 +++++++++++++++++++++++++++-------
docs/_build/man/aioredis.1 | 37 ++++++++++++++++++++++++++++++++-----
setup.cfg | 1 -
tests/log_test.py | 14 ++++++++++++++
tests/py35_pubsub_receiver_test.py | 35 +++++++++++++++++++++++++++++++++++
tests/task_cancellation.py | 34 ++++++++++++++++++++++++++++++++++
11 files changed, 175 insertions(+), 16 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 731cd22..8832f86 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,15 @@
Changes
-------
+0.3.1 (2017-05-09)
+^^^^^^^^^^^^^^^^^^
+
+**FIX**:
+
+* Fix pubsub Receiver missing iter() method
+ (see `#203 <https://github.com/aio-libs/aioredis/issues/203>`_);
+
+
0.3.0 (2017-01-11)
^^^^^^^^^^^^^^^^^^
diff --git a/PKG-INFO b/PKG-INFO
index 06f0d89..5ece422 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: aioredis
-Version: 0.3.0
+Version: 0.3.1
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis
Author: Alexey Popravka
@@ -141,6 +141,15 @@ Description: aioredis
Changes
-------
+ 0.3.1 (2017-05-09)
+ ^^^^^^^^^^^^^^^^^^
+
+ **FIX**:
+
+ * Fix pubsub Receiver missing iter() method
+ (see `#203 <https://github.com/aio-libs/aioredis/issues/203>`_);
+
+
0.3.0 (2017-01-11)
^^^^^^^^^^^^^^^^^^
diff --git a/aioredis.egg-info/PKG-INFO b/aioredis.egg-info/PKG-INFO
index 06f0d89..5ece422 100644
--- a/aioredis.egg-info/PKG-INFO
+++ b/aioredis.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: aioredis
-Version: 0.3.0
+Version: 0.3.1
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis
Author: Alexey Popravka
@@ -141,6 +141,15 @@ Description: aioredis
Changes
-------
+ 0.3.1 (2017-05-09)
+ ^^^^^^^^^^^^^^^^^^
+
+ **FIX**:
+
+ * Fix pubsub Receiver missing iter() method
+ (see `#203 <https://github.com/aio-libs/aioredis/issues/203>`_);
+
+
0.3.0 (2017-01-11)
^^^^^^^^^^^^^^^^^^
diff --git a/aioredis.egg-info/SOURCES.txt b/aioredis.egg-info/SOURCES.txt
index a48f199..56b1bbe 100644
--- a/aioredis.egg-info/SOURCES.txt
+++ b/aioredis.egg-info/SOURCES.txt
@@ -75,6 +75,7 @@ tests/geo_commands_test.py
tests/hash_commands_test.py
tests/hyperloglog_commands_test.py
tests/list_commands_test.py
+tests/log_test.py
tests/multi_exec_test.py
tests/pool_test.py
tests/pubsub_commands_test.py
@@ -83,6 +84,7 @@ tests/py35_generic_commands_test.py
tests/py35_hash_commands_test.py
tests/py35_pool_test.py
tests/py35_pubsub_commands_test.py
+tests/py35_pubsub_receiver_test.py
tests/py35_set_commands_test.py
tests/py35_sorted_set_commands_test.py
tests/reconnect_test.py
@@ -92,5 +94,6 @@ tests/set_commands_test.py
tests/sorted_set_commands_test.py
tests/ssl_test.py
tests/string_commands_test.py
+tests/task_cancellation.py
tests/task_cancellation_test.py
tests/transaction_commands_test.py
\ No newline at end of file
diff --git a/aioredis/__init__.py b/aioredis/__init__.py
index 6f993a0..b259ad1 100644
--- a/aioredis/__init__.py
+++ b/aioredis/__init__.py
@@ -19,7 +19,7 @@ from .errors import (
)
-__version__ = '0.3.0'
+__version__ = '0.3.1'
# make pyflakes happy
(create_connection, RedisConnection,
diff --git a/aioredis/pubsub.py b/aioredis/pubsub.py
index 1208e2f..1e4d30d 100644
--- a/aioredis/pubsub.py
+++ b/aioredis/pubsub.py
@@ -111,8 +111,10 @@ class Channel(AbcChannel):
>>> async for msg in ch.iter():
... print(msg)
"""
- return _ChannelIter(self, encoding=encoding,
- decoder=decoder)
+ return _IterHelper(self,
+ is_active=lambda ch: ch.is_active,
+ encoding=encoding,
+ decoder=decoder)
@asyncio.coroutine
def wait_message(self):
@@ -156,12 +158,13 @@ class Channel(AbcChannel):
if PY_35:
- class _ChannelIter:
+ class _IterHelper:
- __slots__ = ('_ch', '_args', '_kw')
+ __slots__ = ('_ch', '_is_active', '_args', '_kw')
- def __init__(self, ch, *args, **kw):
+ def __init__(self, ch, is_active, *args, **kw):
self._ch = ch
+ self._is_active = is_active
self._args = args
self._kw = kw
@@ -171,7 +174,7 @@ if PY_35:
@asyncio.coroutine
def __anext__(self):
- if not self._ch.is_active:
+ if not self._is_active(self._ch):
raise StopAsyncIteration # noqa
msg = yield from self._ch.get(*self._args, **self._kw)
if msg is None:
@@ -272,8 +275,11 @@ class Receiver:
"""Wait for and return pub/sub message from one of channels.
Return value is either:
+
* tuple of two elements: channel & message;
+
* tuple of three elements: pattern channel, (target channel & message);
+
* or None in case Receiver is stopped.
:raises aioredis.ChannelClosedError: If listener is stopped
@@ -281,7 +287,7 @@ class Receiver:
"""
assert decoder is None or callable(decoder), decoder
if not self.is_active:
- if not self._running:
+ if not self._running: # inactive but running
raise ChannelClosedError()
return
ch, msg = yield from self._queue.get()
@@ -323,6 +329,20 @@ class Receiver:
"""
self._running = False
+ if PY_35:
+ def iter(self, *, encoding=None, decoder=None):
+ """Returns async iterator.
+
+ Usage example:
+
+ >>> async for ch, msg in mpsc.iter():
+ ... print(ch, msg)
+ """
+ return _IterHelper(self,
+ is_active=lambda r: r.is_active or r._running,
+ encoding=encoding,
+ decoder=decoder)
+
# internal methods
def _put_nowait(self, data, *, sender):
diff --git a/docs/_build/man/aioredis.1 b/docs/_build/man/aioredis.1
index 1859709..dd4d964 100644
--- a/docs/_build/man/aioredis.1
+++ b/docs/_build/man/aioredis.1
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
-.TH "AIOREDIS" "1" "Jan 11, 2017" "0.3" "aioredis"
+.TH "AIOREDIS" "1" "May 09, 2017" "0.3" "aioredis"
.SH NAME
aioredis \- aioredis Documentation
.
@@ -3231,7 +3231,7 @@ Arguments can be instances of \fBChannel\fP\&.
\fBWARNING:\fP
.INDENT 0.0
.INDENT 3.5
-Current release (0.3.0) of the library \fBdoes not support\fP
+Current release (0.3.1) of the library \fBdoes not support\fP
\fI\%Redis Cluster\fP in a full manner.
It provides only several API methods which may be changed in future.
.UNINDENT
@@ -3449,9 +3449,14 @@ Read\-only channels dict.
Wait for and return pub/sub message from one of channels.
.sp
Return value is either:
-* tuple of two elements: channel & message;
-* tuple of three elements: pattern channel, (target channel & message);
-* or None in case Receiver is stopped.
+.INDENT 7.0
+.IP \(bu 2
+tuple of two elements: channel & message;
+.IP \(bu 2
+tuple of three elements: pattern channel, (target channel & message);
+.IP \(bu 2
+or None in case Receiver is stopped.
+.UNINDENT
.INDENT 7.0
.TP
.B Raises
@@ -3466,6 +3471,20 @@ Returns True if listener has any active subscription.
.UNINDENT
.INDENT 7.0
.TP
+.B iter(*, encoding=None, decoder=None)
+Returns async iterator.
+.sp
+Usage example:
+.sp
+.nf
+.ft C
+>>> async for ch, msg in mpsc.iter():
+\&... print(ch, msg)
+.ft P
+.fi
+.UNINDENT
+.INDENT 7.0
+.TP
.B pattern(pattern)
Create a pattern channel.
.sp
@@ -4336,6 +4355,14 @@ Adopted version of \fI\%unittest.TestCase.assertRaisesRegex()\fP\&.
.UNINDENT
.SH RELEASES
.SS Recent
+.SS 0.3.1 (2017\-05\-09)
+.sp
+\fBFIX\fP:
+.INDENT 0.0
+.IP \(bu 2
+Fix pubsub Receiver missing iter() method
+(see \fI\%#203\fP);
+.UNINDENT
.SS 0.3.0 (2017\-01\-11)
.sp
\fBNEW\fP:
diff --git a/setup.cfg b/setup.cfg
index 48f5f1e..f5fed93 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -14,5 +14,4 @@ source = aioredis,tests
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff --git a/tests/log_test.py b/tests/log_test.py
new file mode 100644
index 0000000..aca3171
--- /dev/null
+++ b/tests/log_test.py
@@ -0,0 +1,14 @@
+import os
+import pytest
+
+
+ at pytest.mark.run_loop
+def test_aioredis_debug_env_var():
+ os.environ['AIOREDIS_DEBUG'] = 'x'
+ import aioredis
+ conn = yield from aioredis.create_connection(('localhost', 6379))
+ try:
+ pass
+ finally:
+ conn.close()
+ yield from conn.wait_closed()
diff --git a/tests/py35_pubsub_receiver_test.py b/tests/py35_pubsub_receiver_test.py
new file mode 100644
index 0000000..70ad600
--- /dev/null
+++ b/tests/py35_pubsub_receiver_test.py
@@ -0,0 +1,35 @@
+import asyncio
+import pytest
+
+from aioredis.pubsub import Receiver
+
+
+ at pytest.mark.run_loop
+async def test_pubsub_receiver_iter(create_redis, server, loop):
+ sub = await create_redis(server.tcp_address, loop=loop)
+ pub = await create_redis(server.tcp_address, loop=loop)
+
+ mpsc = Receiver(loop=loop)
+
+ async def coro(mpsc):
+ lst = []
+ async for msg in mpsc.iter():
+ lst.append(msg)
+ return lst
+
+ tsk = asyncio.ensure_future(coro(mpsc), loop=loop)
+ snd1, = await sub.subscribe(mpsc.channel('chan:1'))
+ snd2, = await sub.subscribe(mpsc.channel('chan:2'))
+ snd3, = await sub.psubscribe(mpsc.pattern('chan:*'))
+
+ await pub.publish_json('chan:1', {'Hello': 'World'})
+ await pub.publish_json('chan:2', ['message'])
+ mpsc.stop()
+ await asyncio.sleep(0, loop=loop)
+ assert await tsk == [
+ (snd1, b'{"Hello": "World"}'),
+ (snd3, (b'chan:1', b'{"Hello": "World"}')),
+ (snd2, b'["message"]'),
+ (snd3, (b'chan:2', b'["message"]')),
+ ]
+ assert not mpsc.is_active
diff --git a/tests/task_cancellation.py b/tests/task_cancellation.py
new file mode 100644
index 0000000..c431ccd
--- /dev/null
+++ b/tests/task_cancellation.py
@@ -0,0 +1,34 @@
+import unittest
+import asyncio
+
+from ._testutil import BaseTest, run_until_complete
+
+
+class CancellationTest(BaseTest):
+
+ @run_until_complete
+ @unittest.expectedFailure
+ def test_future_cancellation_but_blocks_connection(self):
+ conn1 = yield from self.create_connection(
+ ('localhost', 6379), loop=self.loop)
+ conn2 = yield from self.create_connection(
+ ('localhost', 6379), loop=self.loop)
+
+ @asyncio.coroutine
+ def task1():
+ yield from asyncio.sleep(2, loop=self.loop)
+ yield from conn1.execute('LPUSH', 'a_list', 'value')
+
+ sec1, ms = yield from conn2.execute('TIME')
+ fut = conn2.execute('BLPOP', 'a_list', 3)
+ asyncio.async(task1(), loop=self.loop)
+ try:
+ yield from asyncio.wait_for(fut, .1, loop=self.loop)
+ except asyncio.TimeoutError:
+ pass
+ self.assertTrue(fut.cancelled())
+ # Future is cancelled but connection is blocked
+ # with BLPOP timeout
+
+ sec2, ms = yield from conn2.execute('TIME')
+ self.assertEqual(int(sec2) - int(sec1), 1)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/aioredis.git
More information about the Python-modules-commits
mailing list