Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REQUEST_TIMEOUT & RESPONSE_TIMEOUT not working #2922

Open
1 task done
Senhaji-Rhazi-Hamza opened this issue Feb 28, 2024 · 0 comments
Open
1 task done

REQUEST_TIMEOUT & RESPONSE_TIMEOUT not working #2922

Senhaji-Rhazi-Hamza opened this issue Feb 28, 2024 · 0 comments
Labels

Comments

@Senhaji-Rhazi-Hamza
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using sanic 23.12.1

I'm trying to use timeout feature to handle the time processing of the request, i'm using the exact same code presented
in the example :
https://github.com/sanic-org/sanic/blob/main/examples/request_timeout.py

It doesn't seems to work

Code snippet

import asyncio

from sanic import Sanic, response
from sanic.config import Config
from sanic.exceptions import RequestTimeout


Config.REQUEST_TIMEOUT = 1
app = Sanic("Example")


@app.route("/")
async def test(request):
    await asyncio.sleep(3)
    return response.text("Hello, world!")


@app.exception(RequestTimeout)
def timeout(request, exception):
    return response.text("RequestTimeout from error_handler.", 408)


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

Expected Behavior

The expected behaviour is to have RequestTimeout Exception raised

How do you run Sanic?

Sanic CLI

Operating System

Linux

Sanic Version

23.12.1

Additional context

By trying to understand what happening, in the checkt_timeouts function that is present under sanic/server/protocols/http_protocol.py, it seems that self._http.stage does'nt get updated to Stage.REQUEST or Stage.HANDLER, it always has the value Stage.IDLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant