我有一个对服务器的API调用,在该服务器上我正在使用芹菜做一些处理。 芹菜的输出传递回客户端。
我用了
som = task_async_get_cached_session.delay('session_123')
print 'before'
result = som.get(timeout=1)
print 'after'
我查看了celery -l INFO
,任务succeeded in 0.024465521s: {data: {session_123: something}}
中succeeded in 0.024465521s: {data: {session_123: something}}
但是我的客户没有得到响应,因此我设置了超时时间,现在我得到The operation timed out. (<class 'celery.exceptions.TimeoutError'>)
The operation timed out. (<class 'celery.exceptions.TimeoutError'>)
当我查看日志跟踪时,仅打印before
。 我的问题是,当您希望将celery任务生成的结果传递给客户端时,如何在不使用get()
情况下使用celery?
我知道get()
会将我的API调用转换为同步,但是我还有什么选择? 芹菜的真正用途是什么? 还有其他方法可以将我的API更改为“异步”吗?