Closed YraganTron closed 1 year ago
@YraganTron if i understood you correctly, despite you use async callback, code inside is absolutely synchronous, so no chance for loop to switch context and process other tasks. Sorry, there are no miracles. What I could advice - run fastapi server in different process. And try to do calback as asynchronous as possible, for example use async db driver.
I have the following example which simulates a long message processing time. When receiving messages more than 2 per second, we will start to have problems. We will not have time to process messages and eventually the loop will be completely blocked. Any call to an endpoint test is doomed to fail. I would like to know how to proceed in such a situation. Maybe you should add some kind of restriction on the number of messages processed in the config?
I could do something like this to not block the loop, but the problem is that the delay when calling any endpoint is still saved. Just like if I want to stop the webserver, it will still process messages for some time that it did not have time to process.