#22420: Postgresql connections not being dropped between tests? -----------------------------------+-------------------------------------- Reporter: bacongobbler | Owner: nobody Type: Bug | Status: new Component: Testing framework | Version: 1.6 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------+-------------------------------------- Changes (by gabrtv):
* status: closed => new * resolution: invalid => Comment: This is still an issue for us, but we were able to find a workaround I wanted to share: 1. The problem is related to using threads that access the database inside a TransactionTestCase 2. Explicitly closing database connections before the threads exit seems to resolve the issue We are using the following decorator: {{{ def close_db_connections(func, *args, **kwargs): """ Decorator to close db connections during threaded execution Note this is necessary to work around: https://code.djangoproject.com/ticket/22420 """ def _inner(*args, **kwargs): func(*args, **kwargs) for conn in connections.all(): conn.close() return _inner }}} At first blush, it seems like TransactionTestCase may not be threadsafe. While I'd love to work on a minimal example of the broken behavior, I don't have time. :( Hopefully this workaround is helpful to others who may run across this problem. Re-opening in case someone wants to take some action. -- Ticket URL: <https://code.djangoproject.com/ticket/22420#comment:10> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/070.fcc8da173126c2c8c0c978d0f6899fe2%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.