In my celery I tried printing inside a task, but I cant seem to output the data even in console.
Here is my structure:
/app.py
@app.route('//create', methods = ['POST'])
def create_file():
request.form .......
callback = build_file.s(name, address)
header = [ send_param.s( id, key ) for key in request_api.keys() ]
result = chord(header)(callback)
@celery.task(name='app.send_param', routing_key='send_param', queue='send_param', retry=False, bind=True)
def send_param(seld, id, key):
//do something
print 'NOT WORKING'
@celery.task(name='app.build_file', routing_key='send_param', queue='send_param', retry=False, bind=True)
def build_file(seld, name, address):
//do something
print 'NOT WORKING'
When printing within my create_file function it does print, but within my tasks it doesnt.
The most straightforward solution will be to:
1) Configure a Logger instance which will capture all output from logger.info()
(and other log levels) and put it into a local file or just stdout
2) While configuring, set
app.conf.update(CELERYD_HIJACK_ROOT_LOGGER=False)
to prevent Celery from removing any previously configured Loggers (more info: http://docs.celeryproject.org/en/latest/configuration.html#logging ).
Another option could be using the Siglans: http://docs.celeryproject.org/en/latest/userguide/signals.html
but it is a little bit more involved and probably an overkill in your situation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.