From fbe817bb251a04c9f5e7460320ca6074a9c35702 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 6 Jun 2015 23:36:15 -0700 Subject: [PATCH] Allow providing a non-standard condition class to the r/w lock --- ChangeLog | 5 ++++- fasteners/lock.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 894700f..fbb2568 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -0.9 +0.9: + - Allow providing a non-standard (eventlet or + other condition class) to the r/w lock for + cases where it is useful to do so. 0.8: - Add fastener logo (from openclipart). - Ensure r/w writer -> reader -> writer diff --git a/fasteners/lock.py b/fasteners/lock.py index f9969dc..fe95181 100644 --- a/fasteners/lock.py +++ b/fasteners/lock.py @@ -132,11 +132,12 @@ class ReaderWriterLock(object): return eventlet.getcurrent return threading.current_thread - def __init__(self, find_eventlet=True): + def __init__(self, find_eventlet=True, + condition_cls=threading.Condition): self._writer = None self._pending_writers = collections.deque() self._readers = collections.deque() - self._cond = threading.Condition() + self._cond = condition_cls() self._current_thread = self._fetch_current_thread_functor( find_eventlet=find_eventlet)