{"action":"created","issue":{"url":"https://api.github.com/repos/celery/django-celery/issues/402","repository_url":"https://api.github.com/repos/celery/django-celery","labels_url":"https://api.github.com/repos/celery/django-celery/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/celery/django-celery/issues/402/comments","events_url":"https://api.github.com/repos/celery/django-celery/issues/402/events","html_url":"https://github.com/celery/django-celery/issues/402","id":119290179,"number":402,"title":"DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread.","user":{"login":"SeanHayes","id":134373,"avatar_url":"https://avatars.githubusercontent.com/u/134373?v=3","gravatar_id":"","url":"https://api.github.com/users/SeanHayes","html_url":"https://github.com/SeanHayes","followers_url":"https://api.github.com/users/SeanHayes/followers","following_url":"https://api.github.com/users/SeanHayes/following{/other_user}","gists_url":"https://api.github.com/users/SeanHayes/gists{/gist_id}","starred_url":"https://api.github.com/users/SeanHayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeanHayes/subscriptions","organizations_url":"https://api.github.com/users/SeanHayes/orgs","repos_url":"https://api.github.com/users/SeanHayes/repos","events_url":"https://api.github.com/users/SeanHayes/events{/privacy}","received_events_url":"https://api.github.com/users/SeanHayes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2015-11-28T12:09:54Z","updated_at":"2016-08-29T16:41:29Z","closed_at":null,"body":"Django==1.8.6\r\ncelery==3.1.19\r\ndjango-celery==3.1.17\r\nPostgresql\r\n\r\nI keep getting this error, I've tried both eventlet and the default worker type:\r\n\r\n    Task mysite.giftcards.tasks.EDeliverTask with id 32b60bb3-a538-4990-b854-775f3c97383e raised exception: ‘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 139742333142032 and this is thread id 139742187524816.\",)'\r\n\r\n    Task was called with args: [] kwargs: {'order_pk': 1}.\r\n\r\n    The contents of the full traceback was:\r\n\r\n    Traceback (most recent call last):\r\n\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/app/trace.py\", line 253, in trace_task\r\n      I, R, state, retval = on_error(task_request, exc, uuid)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/app/trace.py\", line 201, in on_error\r\n      R = I.handle_error_state(task, eager=eager)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/app/trace.py\", line 85, in handle_error_state\r\n      }[self.state](task, store_errors=store_errors)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/app/trace.py\", line 118, in handle_failure\r\n      req.id, exc, einfo.traceback, request=req,\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/backends/base.py\", line 121, in mark_as_failure\r\n      traceback=traceback, request=request)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/celery/backends/base.py\", line 257, in store_result\r\n      request=request, **kwargs)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/djcelery/backends/database.py\", line 29, in _store_result\r\n      traceback=traceback, children=self.current_task_children(request),\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/djcelery/managers.py\", line 42, in _inner\r\n      return fun(*args, **kwargs)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/djcelery/managers.py\", line 181, in store_result\r\n      'meta': {'children': children}})\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/djcelery/managers.py\", line 87, in update_or_create\r\n      return get_queryset(self).update_or_create(**kwargs)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/djcelery/managers.py\", line 70, in update_or_create\r\n      obj, created = self.get_or_create(**kwargs)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/query.py\", line 405, in get_or_create\r\n      return self.get(**lookup), False\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/query.py\", line 328, in get\r\n      num = len(clone)\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/query.py\", line 144, in __len__\r\n      self._fetch_all()\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/query.py\", line 965, in _fetch_all\r\n      self._result_cache = list(self.iterator())\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/query.py\", line 238, in iterator\r\n      results = compiler.execute_sql()\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py\", line 838, in execute_sql\r\n      cursor = self.connection.cursor()\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/backends/base/base.py\", line 160, in cursor\r\n      self.validate_thread_sharing()\r\n    File \"/srv/mysite.co/.venv/local/lib/python2.7/site-packages/django/db/backends/base/base.py\", line 421, in validate_thread_sharing\r\n      % (self.alias, self._thread_ident, thread.get_ident()))\r\n\r\n    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 139742333142032 and this is thread id 139742187524816.\r\n\r\n    — Just to let you know, py-celery at celery@default.queue."},"comment":{"url":"https://api.github.com/repos/celery/django-celery/issues/comments/243179794","html_url":"https://github.com/celery/django-celery/issues/402#issuecomment-243179794","issue_url":"https://api.github.com/repos/celery/django-celery/issues/402","id":243179794,"user":{"login":"pappacena","id":1213561,"avatar_url":"https://avatars.githubusercontent.com/u/1213561?v=3","gravatar_id":"","url":"https://api.github.com/users/pappacena","html_url":"https://github.com/pappacena","followers_url":"https://api.github.com/users/pappacena/followers","following_url":"https://api.github.com/users/pappacena/following{/other_user}","gists_url":"https://api.github.com/users/pappacena/gists{/gist_id}","starred_url":"https://api.github.com/users/pappacena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pappacena/subscriptions","organizations_url":"https://api.github.com/users/pappacena/orgs","repos_url":"https://api.github.com/users/pappacena/repos","events_url":"https://api.github.com/users/pappacena/events{/privacy}","received_events_url":"https://api.github.com/users/pappacena/received_events","type":"User","site_admin":false},"created_at":"2016-08-29T16:41:29Z","updated_at":"2016-08-29T16:41:29Z","body":"+1"}}
{"actor":{"display_login":"pappacena"}}