Created
April 9, 2016 10:55
-
-
Save ryanmcgrath/f759d0bbc3d670214884cb14c38e11b4 to your computer and use it in GitHub Desktop.
Getting around uwsgidecorators import failure issues when using uwsgi spooler functionality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
# This module is only available when running under uwsgi | |
# in production. We try to import it, but if it fails we're | |
# running in development and should just pass a decorator that'll | |
# run it back immediately. | |
from uwsgidecorators import spool | |
except: | |
def spool(fn): | |
def _spool(**kwargs): | |
return fn(kwargs) | |
fn.spool = _spool | |
return fn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use uwsgi, you can make use of the spooler functionality to avoid having to do the usual Celery+[workers/etc] setup. There's one annoying piece that's not well documented around the internet, which is that if you're using the
@spool
decorator/methods, and you're not running in uwsgi (like a development server) you'll have everything blow up as uwsgi injects the package for you under ordinary circumstances. This patches it so that, if you're not under uwsgi, it'll just auto-execute the spooler method. Works perfectly for me in development.