You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm afraid it's not possible to avoid this bug in this library because of the intrinsic nature of the Middleware logic.
Summarizing a bit the issue: it's causing that HTTP responses are not sent until all background tasks are finished due to responses are awaited in middlewares (there is a stack of middlewares so everyone will await the next one) and background tasks are executed in the same thread and process.
For our case it's not possible to do any other thing because we need the response itself to extract some data, such as execution time, status code, etc.
We have to wait how the issue is resolved in Starlette and meanwhile:
Run the background tasks using multiprocessing to avoid blocking the main process.
Someone mentioned in encode/starlete#919 that using hypercorn the problem isn't happening.
Hello,
Just letting you know that your middleware is impacted by this issue in Starlette.
I did not investigate much but it seems that you could fix it without waiting for a fix in Starlette (if you feel like it of course).
Best Regards
The text was updated successfully, but these errors were encountered: