pool._DBProxy.get_pool doesn't look threadsafe

Issue #799 resolved
Former user created an issue

I was debugging some issues and ran across some code that doesn't look thread-safe - the code in pool._DBProxy.get_pool (called by pool._DBProxy.connect) does not appear to be thread-safe, and I'm not enough of a SQLAlchemy expert to understand the possible implications of this, so I thought I would at least let you know.

This is in 0.3.10

Comments (3)

  1. Mike Bayer repo owner

    its very old code, from the first versions of SA. its not threadsafe in that theres a chance that extra pools can be created, although they'd immediately fall out of scope and then be gone for the rest of the app's lifespan..so the failure here wouldnt create very noticeable effects (additionally this is a very rarely used feature).

    the mutex should be added in a new block that occurs after the KeyError so that no mutexing occurs unless the pool is not found (a second check should happen inside the mutex to ensure no other thread created it).

  2. Log in to comment