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

Is there a way to set timeouts? #213

Open
pfortini opened this issue Apr 5, 2021 · 2 comments
Open

Is there a way to set timeouts? #213

pfortini opened this issue Apr 5, 2021 · 2 comments

Comments

@pfortini
Copy link

pfortini commented Apr 5, 2021

I just started using bjoern on my project and it's been going great so far. What I'd like to know is if there's a way to globally set a timeout for requests.

My project is a very simple API with a few endpoints, but sometimes the request will take too long and I'd like to set a timeout for all endpoints

the code looks something like this:

from flask import Flask

app = Flask(__name__)
host = "0.0.0.0"
port = 5000

@app.route("/up", methods=["POST"])
def up():
    res = doSomething()
    return(res)

@app.route("/down", methods=["POST"])
def down():
    res = doSomethingElse()
    return(res)

if __name__ == "__main__":
    import bjoern
    bjoern.run(app, host, port)

what I'd like to happen is to end the connection if either /up or /down takes more than 20s. is that possible?

@jonashaag
Copy link
Owner

Hi! Not implemented, and I'm not sure it's supposed to be implemented in the web server. It's probably better to implement it in your application.

@pfortini
Copy link
Author

pfortini commented Apr 6, 2021

I see. I'll try to implement it on the application side then. Thanks!

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

No branches or pull requests

2 participants