Hi Vernon, On 17 mai 2013, at 13:26, VernonCole <[email protected]> wrote:
> After much debugging it looks like my database proxy server may be running > out of worker threads: it uses one for each cursor. With DB-API adapters, the connections are expected to be expensive and cursors cheap. (If this sounds obscure, I recommend re-reading PEP 249.) It appears that creating a cursor is expensive in your setup, and that's the problem. Roughly, your proxy server can use one thread per connection, but not per cursor. It's hard to give accurate advice here; overall I think that's why you're running into trouble. > My traces show that, when running the test suite in django-mssql (using > ./manage.py test) cursors are neither re-used, nor closed. Django can create a lot of cursors and that isn't expected to be a problem. Django should close these cursors and I'm not convinced it always does. If you could file a bug report with a bit more information (X leaks an unclosed cursor) that would help. > My verbose trace shows, for each new test class, a connection is created, a > cursor is created, one SQL statement is run, another cursor is created, > another SQL statement run, etc., until the test completes. Then the > connection is closed, which (inside my adapter) triggers the closing of all > of those cursors, sometimes a dozen or more. That's very, very weird. The test suite is supposed to keep a single connection opened during the entire test run — that's required to make it work with an in-memory SQLite database (ignoring multi-db tests). > The idea of re-using connections in 1.6 causes me to _really_ worry. Is this > behaviour expected but only happens in testing? Fortunately I don't think persistent connections are related to the problems you're seeing. They're about keeping connections, while your problems seem to revolve around cursors. -- Aymeric. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
