diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-13 23:50:14 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-13 23:50:14 -0400 |
commit | cc4de1fd3330d4b2d778226cc45c3b792875f0a9 (patch) | |
tree | df2caa9c29926775823c95696e168d588026a595 /cherrypy/test/test_session.py | |
parent | 84427067f20de193e277e28d36239b99d7f18be8 (diff) | |
parent | afdcf1d87020d0143ac0be564fad75e860641c1c (diff) | |
download | cherrypy-git-cc4de1fd3330d4b2d778226cc45c3b792875f0a9.tar.gz |
Merged in shroom/cherrypy (pull request #50)
Fix race condition in session clean up.
Diffstat (limited to 'cherrypy/test/test_session.py')
-rwxr-xr-x | cherrypy/test/test_session.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py index 355a2a3a..4bea7f6f 100755 --- a/cherrypy/test/test_session.py +++ b/cherrypy/test/test_session.py @@ -1,6 +1,5 @@ import os localDir = os.path.dirname(__file__) -import sys import threading import time @@ -358,10 +357,24 @@ class SessionTest(helper.CPWebCase): else: self.fail("Unknown session id in cache: %r", cache) + def test_8_Ram_Cleanup(self): + def lock(): + s1 = sessions.RamSession() + s1.acquire_lock() + time.sleep(1) + s1.release_lock() + + t = threading.Thread(target=lock) + t.start() + s2 = sessions.RamSession() + s2.clean_up() + self.assertEqual(len(sessions.RamSession.locks), 1, 'Clean up should not remove active lock') + t.join() + import socket try: - import memcache + import memcache # NOQA host, port = '127.0.0.1', 11211 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, @@ -436,7 +449,7 @@ else: ## sys.stdout.write("%d " % index) if not self.body.isdigit(): self.fail(self.body) - data_dict[index] = v = int(self.body) + data_dict[index] = int(self.body) # Start <request_count> concurrent requests from # each of <client_thread_count> clients |