asyncio and coroutines vs task queues

后端 未结 2 687
有刺的猬
有刺的猬 2021-02-05 03:57

I\'ve been reading about asyncio module in python 3, and more broadly about coroutines in python, and I can\'t get what makes asyncio such a great tool. I have the feeling that

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 04:38

    Adding to the above answer:

    If the task at hand is I/O bound and operates on a shared data, coroutines and asyncio are probably the way to go.

    If on the other hand, you have CPU-bound tasks where data is not shared, a multiprocessing system like Celery should be better.

    If the task at hand is a both CPU and I/O bound and sharing of data is not required, I would still use Celery.You can use async I/O from within Celery!

    If you have a CPU bound task but with the need to share data, the only viable option as I see now is to save the shared data in a database. There have been recent attempts like pyparallel but they are still work in progress.

提交回复
热议问题