Python Forum
problems with flask and celery - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: problems with flask and celery (/thread-33473.html)



problems with flask and celery - Phantomsec - Apr-27-2021

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?


RE: problems with flask and celery - Larz60+ - Apr-28-2021

Please show complete and unaltered error traceback (surrounded by bbcode error tags).
This traceback contains important information useful for debugging.


RE: problems with flask and celery - Phantomsec - Apr-28-2021

(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