I have a celery that is called, just ignite the execution of some parallel code inside a twisted reactor. is. For example, there is no sample (runan) code:
def run_task_in_reactor (): # to do this takes some time do_something () do_something_more () @ celery.task def run_task () : The print "reactor was started" reactor calfarththread (run_task_in_rector) (For simplicity, please assume that the reactor is already running when the worker gets the work; As soon as the other thread in my reactor When I call run_task.delay () , the task is finished very quickly (because it run_task_in_reactor () does not wait to finish, only determines its execution time in reactor). And, when run_task_in_reactor () runs at the end, do_something () or do_something_more () can throw an exception, which will be untold. To use pika to consume my line, for example, to inform the worker about the correct completion of the job, I do_something_more () However, inside the celery, this does not seem possible (or, at least, I do not know how to make the same effect complete) Also, I can not remove the reactor because it One requirement is using some third-party code. I also appreciate other ways to achieve the same result.
Use reactor. BlockingCallFromThread instead.
No comments:
Post a Comment