Terminate the pipeline once the request connect through FastAPI is disconnected #8751
Replies: 2 comments 4 replies
-
Hello! Could you please explain more about your use case? I also recommend you take a look at Hayhooks: our project to deploy Haystack pipelines behind a REST API. It also makes it easy to deploy and undeploy Pipelines. (FYI @mpangrazzi) |
Beta Was this translation helpful? Give feedback.
-
Hi @cloudissue! To achieve what you want, you need to implement something which basically continuously polls the request and check the status of the client side. You can take this answer as a starting point: this user has implement an async context manager which will cancel when a client request disconnects. It should be enough to handle your use case. Out of curiosity, can you be more specific about your use case? Does the client requests coming from a browser? So e.g. if one closes the tab while awaiting the response, the request will be cancelled? |
Beta Was this translation helpful? Give feedback.
-
I am totally new with Haystack and I am wondering if there are some way to terminate the running pipeline.
I have built the RAG based on Haystack as an open API.
The original codes should be something as below.
Once the request is disconnected during the process, I'd like to stop the running process of the pipeline.
It seems that once the pipeline is started, it could not be stopped.
I have followed the discussion in FastAPI project to handle the event as "Connection Disconnected".
The test passed with sleep function, but it does work with the pipeline.
The pipeline will be run completely after I stop the connection script.
Is there any way or function to handle the lifecycle of the running pipeline or could be used to stop the process?
Could you please kindly share your suggestions and thanks a lot for your time.
Beta Was this translation helpful? Give feedback.
All reactions