Python Forum

Full Version: problems with flask and celery
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def make_celery(app):
    celery = Celery(
        app.import_name,
        backend=app.config['CELERY_RESULT_BACKEND'],
        broker=app.config['CELERY_BROKER_URL']
    )
    celery.conf.update(app.config)

    class ContextTask(celery.Task):
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return self.run(*args, **kwargs)

    celery.Task = ContextTask
    return celery


app = Flask(__name__)
app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'
app.secret_key = '6969'
api = Api(app)
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
@celery.task
def send():
  p = subprocess.run(['python3 calc.py'], cwd=r"/var/www/webApp/webApp/", shell=True,stdin=None, stdout=None, stderr=None, close_fds=True)
  return
my issue and the only error i can see to access: Object of type 'module' is not JSON serializable

anyone help?
Please show complete and unaltered error traceback (surrounded by bbcode error tags).
This traceback contains important information useful for debugging.
(Apr-28-2021, 10:26 AM)Larz60+ Wrote: [ -> ]Please show complete and unaltered error traceback (surrounded by bbcode error tags).
This traceback contains important information useful for debugging.

the problem is i cant get a traceback. celery handles the error and outputs the error i stated