﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1442	[patch] Fixing multithreading problem with various database backends	eugene@…	Adrian Holovaty	"This patch supersedes tickets #463, #900, and #1237. Instead of lock-based connection pools it uses TLS (thread local storage). TLS is implemented by python 2.4 natively (threading.local), and by stub for python 2.3. The stub is taken verbatim from python 2.4.2 source distribution. I checked the license and it looks totally compatible with BSD license used by Django. Thank you Joseph Kocherhans (#1268).

The patch solves multithreading problems for MySQL (#463) and PostGreSQL (#900). I couldn't find a ticket for ADO/MSSQL and SQLite, so I didn't convert them. In general the fix is unbelievably simple:

{{{
try:
    # only exists in python 2.4+
    from threading import local
except ImportError:
    # import copy of _thread_local.py from python 2.4
    from django.utils._threading_local import local

class DatabaseWrapper(local):
...
}}}

It can be easily added for other backends, if required. (Additionally MySQL patch implements pinging connections.)"	defect	closed	Database layer (models, ORM)		normal	fixed			Unreviewed	1	0	0	0	0	0
