benoitc/gunicorn — Issue #293: Error related to 1.4 "feature" validate_thread_sharing
Author: wiz
Created: 2012-01-26 09:05:13+00:00
State: open

gevent and eventlet workers stopped working with a [fix](https://github.com/django/django/commit/503f261cdee962f4cc26dbfc3d4a70165757822e) for [issue #17258](https://code.djangoproject.com/ticket/17258)

Traceback:
```
Traceback (most recent call last):
File "/home/wiz/ops/venv/lib/python2.7/site-packages/gunicorn/workers/async.py", line 38, in handle
self.handle_request(req, client, addr)
File "/home/wiz/ops/venv/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 88, in handle_request
super(GeventWorker, self).handle_request(*args)
File "/home/wiz/ops/venv/lib/python2.7/site-packages/gunicorn/workers/async.py", line 64, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/home/wiz/ops/venv/src/django/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/home/wiz/ops/venv/src/django/django/core/handlers/wsgi.py", line 243, in __call__
signals.request_finished.send(sender=self.__class__)
File "/home/wiz/ops/venv/src/django/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/wiz/ops/venv/src/django/django/db/__init__.py", line 46, in close_connection
conn.close()
File "/home/wiz/ops/venv/src/django/django/db/backends/postgresql_psycopg2/base.py", line 133, in close
self.validate_thread_sharing()
File "/home/wiz/ops/venv/src/django/django/db/backends/__init__.py", line 136, in validate_thread_sharing
% (self.alias, self._thread_ident, thread.get_ident()))
DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140373775284000 and this is thread id 53339144.
```