Donald Stufft avatar Donald Stufft committed 82dfba4

Send errors from the RQ worker to Sentry

Comments (0)

Files changed (1)

 import os.path
 import sys
+import raven
 import redis
 import rq
+import rq.contrib.sentry
 # Workaround current bug in docutils:
 import config
 conf = config.Config(os.environ.get("PYPI_CONFIG", "/data/pypi/config.ini"))
 redis_conn = redis.Redis.from_url(conf.redis_url)
+# Create our queues
 if sys.argv[1:]:
     queues = [rq.Queue(name, connection=redis_conn) for name in sys.argv[1:]]
     queues = [rq.Queue(connection=redis_conn)]
+# Create our Worker
 worker = rq.Worker(queues, connection=redis_conn)
+# Create our Sentry Client
+if conf.sentry_dsn:
+    raven_client = raven.Client(conf.sentry_dsn)
+    rq.contrib.sentry.register_sentry(raven_client, worker)
+# Run our worker, fetching jobs from the queue
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.