getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

'Queue' object has no attribute 'all_tasks_done' #1189

Open Skorpyon opened 6 years ago

Skorpyon commented 6 years ago

I using Celery and Django and each time got exception during Celery process exit.

Python==3.6.1

Django==2.0 celery==4.1.0 eventlet==0.22.0 raven==6.5.0

Celery launched with params: -A streamtelecom.settings.celery:consumer_app worker -P eventlet -c 1000 -l warning

When main process receive exit signal it fail with exception in raven:

[2018-01-28 12:07:21,682: WARNING/MainProcess] Error in atexit._run_exitfuncs:
[2018-01-28 12:07:21,682: WARNING/MainProcess] Traceback (most recent call last):
[2018-01-28 12:07:21,682: WARNING/MainProcess] File "/home/anton/streamtelecom/lib/python3.6/site-packages/raven/transport/threaded.py", line 64, in main_thread_terminated
[2018-01-28 12:07:21,683: WARNING/MainProcess] if not self._timed_queue_join(initial_timeout):
[2018-01-28 12:07:21,683: WARNING/MainProcess] File "/home/anton/streamtelecom/lib/python3.6/site-packages/raven/transport/threaded.py", line 92, in _timed_queue_join
[2018-01-28 12:07:21,683: WARNING/MainProcess] queue.all_tasks_done.acquire()
[2018-01-28 12:07:21,683: WARNING/MainProcess] AttributeError
[2018-01-28 12:07:21,683: WARNING/MainProcess] :
[2018-01-28 12:07:21,684: WARNING/MainProcess] 'Queue' object has no attribute 'all_tasks_done'
ashwoods commented 6 years ago

I'm assuming you have configured eventlet to monkey patch Queue and you are using the celery eventlet option. Try using raven.transport.eventlet.EventletHTTPTransport.

dhhagan commented 6 years ago

By any chance, do you know of an example of patching the Sentry class within Flask? It seems straightforward to do it with Client....? This may be a better question for stack overflow, anyways..

m3talstorm commented 6 years ago

@dhhagan

from raven.base import Client
from raven.transport.eventlet import EventletHTTPTransport
from raven.contrib.flask import Sentry

client = Client(dsn='http://...', transport=EventletHTTPTransport)

sentry = Sentry(app, client=client)