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

Allow use custom server class #1091

Closed
wants to merge 1 commit into from

Conversation

abersheeran
Copy link
Member

@abersheeran abersheeran commented Jun 23, 2021

Related links:

This PR will allow passing Server to uvicorn.run via parameters. This will make it easier to handle the problem of long connections that cannot be closed normally.

class Server(uvicorn.Server):
    def handle_exit(self, sig, frame):
        application = self.config.loaded_app
        while not isinstance(application, Starlette):
            application = application.app
        application.should_exit = True
        return super().handle_exit(sig, frame)


uvicorn.run(app, server_class=Server)

@euri10
Copy link
Member

euri10 commented Jun 23, 2021

This PR will allow passing Server to uvicorn.run via parameters. This will make it easier to handle the problem of long connections that cannot be closed normally.

do you have a reproducible application that demonstrate the issue @abersheeran please ?

@euri10
Copy link
Member

euri10 commented Jun 23, 2021

It brings memory, I think #451 is the very same.

I'd prefer to solve the shutdown hanging on tasks not cancelled once ctrl+c has been sent, instead of this patch

but I need to look at it more before making hasty conclusions

@abersheeran
Copy link
Member Author

For the time being, I don’t have a minimal application that can be reproduced, only a large program. But through related link on StackOverflow, this problem should be able to reproduce.

@Kludex
Copy link
Sponsor Member

Kludex commented Jun 25, 2021

There's also #1012 to consider.

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 23, 2022

Closing this in favor of #1248.

@Kludex Kludex closed this Apr 23, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants