sanic
sanic copied to clipboard
Allow RESPONSE_TIMEOUT to be disabled
Is your feature request related to a problem? Please describe. I would like to be able to disable RESPONSE_TIMEOUT so I can have long requests running until completion.
Describe the solution you'd like A common solution to disable timeouts is to set the value to 0.
Additional context N/A
@Tronic and I have talked about an overhaul to timeouts. This is not going to land in the upcoming release, but is absolutely something I'm hoping to get into the end of Summer release.
@GabrielCappelli Setting to float('inf')
should do the trick.
Zero to denote infinity is IMO a bad idea, even if many do it. I've seen inf used quite a bit for this on Python, but None
could also work.
Thanks for the responses. The float('inf')
can do the trick for us with current implementation.
I think the only warning with using inf
is that if you use it on all three timeouts (request, response and keep_alive) you'll schedule a call_later to inf
, which I believe would leak some memory over time.
We're only interested in disabling the RESPONSE_TIMEOUT so it should be fine for our use case.
I believe the timeout polling function is canceled at the end of the connection, but granted, it could be entirely avoided when there are no timeouts at all. However, the no timeout situation should also be quite rare as it makes it trivial to crash your server if you don't implement timeouts or other limits yourself or externally.
Yeah, I've thought about this in the past about how we could implement per-endpoint overrides. The difficulty is that the timers live outside of routing.