From f6932032862d9302d6ce4caf553f8761c2dd4782 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 20 Sep 2015 10:20:06 +0300 Subject: [PATCH] Bump to 0.4.0 --- CHANGES.rst | 5 ++++- README.rst | 12 ++++++------ aiorwlock/__init__.py | 10 +++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0ea4de0..a72ab39 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,10 @@ Changes 0.4.0 (2015-09-20) ^^^^^^^^^^^^^^^^^^ -* Support Python 3.5 +* Support Python 3.5 and `async with` statement + +* rename `.reader_lock` -> `.reader`, `.writer_lock` -> + `.writer`. Backward compatibility is preserved. 0.3.0 (2014-02-11) ^^^^^^^^^^^^^^^^^^ diff --git a/README.rst b/README.rst index 54b51c1..79b390f 100644 --- a/README.rst +++ b/README.rst @@ -36,10 +36,10 @@ Requires Python 3.5+ async def go(): rwlock = aiorwlock.RWLock(loop=loop) - async with rwlock.writer_lock: + async with rwlock.writer: # or same way you can acquire reader lock - # async with rwlock.reader_lock: pass - print("inside writer_lock") + # async with rwlock.reader: pass + print("inside writer") yield from asyncio.sleep(0.1, loop=loop) loop.run_until_complete(go()) @@ -59,10 +59,10 @@ Requires Python 3.3+ @asyncio.coroutine def go(): rwlock = aiorwlock.RWLock(loop=loop) - with (yield from rwlock.writer_lock): + with (yield from rwlock.writer): # or same way you can acquire reader lock - # with (yield from rwlock.reader_lock): pass - print("inside writer_lock") + # with (yield from rwlock.reader): pass + print("inside writer") yield from asyncio.sleep(0.1, loop=loop) loop.run_until_complete(go()) diff --git a/aiorwlock/__init__.py b/aiorwlock/__init__.py index 0aff4a9..d100ee0 100644 --- a/aiorwlock/__init__.py +++ b/aiorwlock/__init__.py @@ -2,7 +2,7 @@ import collections import sys -__version__ = '0.3.0' +__version__ = '0.4.0' __all__ = ['RWLock'] PY_35 = sys.version_info >= (3, 5, 0) @@ -245,15 +245,19 @@ def __init__(self, *, fast=False, loop=None): self._writer_lock = _WriterLock(core) @property - def reader_lock(self): + def reader(self): """The lock used for read, or shared, access""" return self._reader_lock + reader_lock = reader + @property - def writer_lock(self): + def writer(self): """The lock used for write, or exclusive, access""" return self._writer_lock + writer_lock = writer + def __repr__(self): return ''.format(self.reader_lock.__repr__(), self.writer_lock.__repr__())