title: How to integrate Sentry with Huey workers / consumers
body: <p>I'd like to integrate Sentry with <a href="http://huey.readthedocs.io/en/latest/" rel="nofollow noreferrer">Huey task queue</a>'s workers / consumers.</p>
  
  <p>I've seen an issue in both Sentry and Huey's GitHub issues, but I found no definite answer about how to integrate them.</p>
  
  <p>I've read that one way to integrate them is via logging, however I'm storing my API key in the database and loading it from Python code, not from a hard-coded ini file (as is recommended).</p>
  
  <p>Here is how I load Sentry in my main (Pyramid) app:</p>
  
  <pre><code>app = config.make_wsgi_app()
  
  if get_siteconfig(dbsession)['sentry_key_backend']:
      try:
          from raven import Client
          from raven.middleware import Sentry
          client = Client(get_siteconfig(dbsession)['sentry_key_backend'])
          app = Sentry(app, client=client)
      except Exception:
          print('SENTRY init error')
  </code></pre>
  
  <p>Wheres my huey_worker.py is just a bunch of import statement and database setup lines, without an actual <code>app</code> or a function which I could wrap in a try - except block.</p>
  
  <p>What is the recommended way to integrate Sentry in this case?</p>