summaryrefslogtreecommitdiff
path: root/tests/connection_pool.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/connection_pool.py')
-rw-r--r--tests/connection_pool.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/connection_pool.py b/tests/connection_pool.py
index 133bec9..681b46c 100644
--- a/tests/connection_pool.py
+++ b/tests/connection_pool.py
@@ -1,4 +1,6 @@
import redis
+import threading
+import time
import unittest
class ConnectionPoolTestCase(unittest.TestCase):
@@ -17,4 +19,27 @@ class ConnectionPoolTestCase(unittest.TestCase):
r2.select('localhost', 6379, db=9)
self.assertEquals(r1.connection, r2.connection)
- \ No newline at end of file
+ def test_threaded_workers(self):
+ r = redis.Redis(host='localhost', port=6379, db=9)
+ r.set('a', 'foo')
+ r.set('b', 'bar')
+
+ def _info_worker():
+ for i in range(50):
+ _ = r.info()
+ time.sleep(0.01)
+
+ def _keys_worker():
+ for i in range(50):
+ _ = r.keys()
+ time.sleep(0.01)
+
+ t1 = threading.Thread(target=_info_worker)
+ t2 = threading.Thread(target=_keys_worker)
+ t1.start()
+ t2.start()
+
+ for i in [t1, t2]:
+ i.join()
+
+ \ No newline at end of file