Changeset 1012
- Timestamp:
- 03/22/06 02:03:15
- Files:
-
- trunk/cherrypy/test/test_http.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/test_http.py
r1011 r1012 10 10 test.prefer_parent_path() 11 11 12 import gc 12 13 import httplib 14 import threading 13 15 import cherrypy 16 from cherrypy import _cphttptools 14 17 18 19 data = object() 15 20 16 21 class Root: 17 22 def index(self, *args, **kwargs): 23 cherrypy.thread_data.thing = data 18 24 return "Hello world!" 19 25 index.exposed = True … … 41 47 42 48 49 def get_instances(cls): 50 return [x for x in gc.get_objects() if isinstance(x, cls)] 51 52 53 class ReferenceTests(helper.CPWebCase): 54 55 def test_threadlocal_garbage(self): 56 def getpage(): 57 self.getPage('/') 58 self.assertBody("Hello world!") 59 60 ts = [] 61 for _ in range(100): 62 t = threading.Thread(target=getpage) 63 ts.append(t) 64 t.start() 65 66 for t in ts: 67 t.join() 68 69 self.assertEqual(gc.collect(), 0) 70 self.assertEqual(len(get_instances(_cphttptools.Request)), 0) 71 self.assertEqual(len(get_instances(_cphttptools.Response)), 0) 72 self.assertEqual(len(gc.get_referrers(data)), 1) 73 74 43 75 if __name__ == '__main__': 44 76 helper.testmain(server="cherrypy._cpwsgi.WSGIServer")

