Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Race condition when accessing sqla's pdtb_start_timer #65

lukecyca opened this Issue · 3 comments

3 participants


When running my pyramid application via waitress, simultaneous (or near-simultaeous) requests sometimes fail with:

  File "/Network/Cluster/home/luke/.virtualenvs/pyramid/lib/python2.6/site-packages/pyramid_debugtoolbar/panels/", line 47, in _after_cursor_execute
    'duration': stop_timer - conn.pdtb_start_timer,
AttributeError: 'Connection' object has no attribute 'pdtb_start_timer'

I believe this is because multiple queries are executing simultaneously on the same connection, so:
1. Query A causes the sqla panel to set pdtb_start_timer on the Connection object
2. Query B does the same, overwriting the same attribute
3. Query A completes, reads the attribute and deletes it
4. Query B completes, tries to read the attribute but it's already gone

Perhaps the attribute should be stashed in the cursor object rather than the connection object, or perhaps I'm doing something majorly wrong. Unfortunately I'm stretching my knowledge of SQLAlchemy and am not in a position to submit a patch. Let me know how I can help solve this.


Your analysis sounds right to me. I'm not sure what the right way to fix it is either at the moment.


For what it's worth, you can work around this by setting threads = 1 in your server config in the meantime.


Thanks for the tip. That indeed works around the symptom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.