Dask in place of celery for performing background tasks in flask #7439
Unanswered
billlyzhaoyh
asked this question in
Q&A
Replies: 1 comment 9 replies
-
No. Flask (and WSGI in general) is still synchronous so if you wait until the tasks are complete, the request will be pending until then. In order to implement non-blocking tasks with Flask you would need to mimic what is usually done with task queues like Celery: return some ID to the client as soon as a future is created and include an additional endpoint for polling. |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a web app developed in flask that currently uses dask distributed to execute tasks that are essentially solving differential equation with scipy ode
My question is about this portion of documentation on dask distributed describing as_completed call on a group of futures:
"For greater efficiency, you can also ask as_completed to gather the results in the background:
for future, result in as_completed(futures, with_results=True): # y = future.result() # don't need this ...
"
Does this mean when I try to collect the futures back from the distributed client it will be non-blocking? As I am running flask server locally without multi threading and my application does not appear to hand while the local cluster is computing the tasks.
Beta Was this translation helpful? Give feedback.
All reactions