Skip to content

_test_concurrency fails periodically #799

@ghost

Description

Originally reported by: Anonymous


lakin@zedd:~/Projects/cherrypy/trunk/cherrypy$ python test/test.py --test_session
Python version used to run this test script: 2.5.1
CherryPy version 3.1.0beta3
HTTP server version HTTP/1.1 
PID: 25410


Running tests: cherrypy._cpwsgi.CPWSGIServer
test (test_session.MemcachedSessionTest) ... ok
test_0_Session (test_session.SessionTest) ... ok
test_1_Ram_Concurrency (test_session.SessionTest) ... ok
test_2_File_Concurrency (test_session.SessionTest) ... FAIL
test_3_Redirect (test_session.SessionTest) ... ok
test_4_File_deletion (test_session.SessionTest) ... ok
test_5_Error_paths (test_session.SessionTest) ... ok
test_6_regenerate (test_session.SessionTest) ... ok

======================================================================
FAIL: test_2_File_Concurrency (test_session.SessionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/webtest.py", line 278, in __call__
    testMethod()
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/test_session.py", line 180, in test_2_File_Concurrency
    self._test_Concurrency()
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/test_session.py", line 230, in _test_Concurrency
    self.assertEqual(hitcount, expected)
AssertionError: 148 != 151

FAILED (failures=1)
skipped
hit enter

Surprisingly it typically only happens with the FileSession, although from looking at the tests itself it's obvious that there is a concurrency issue.

For instance:
http://cherrypy.org/browser/trunk/cherrypy/test/test_session.py#L57

is not threadsafe. It would be easy for two threads to overwrite each others increments. For reference this is how the threads are created:
http://cherrypy.org/browser/trunk/cherrypy/test/test_session.py#L182l

So, I'm not sure if the session is supposed guard against these sorts of concurrency issues, but my first impression is that it shouldn't. So I'd say the test is broken, thoughts?

Reported by lakin


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions