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

Shutdown handler not working #964

Open
matt24smith opened this issue Sep 16, 2024 · 3 comments · May be fixed by #965
Open

Shutdown handler not working #964

matt24smith opened this issue Sep 16, 2024 · 3 comments · May be fixed by #965
Labels
bug Something isn't working

Comments

@matt24smith
Copy link

Bug Description

Code in shutdown_handler is never executed at shutdown. If a database connection is left open at time of shutdown/restart and --dev is given, a process is left hanging, preventing further use of the port.

Steps to Reproduce

For example, no message is printed upon receiving SIGINT:

from robyn import Robyn

app = Robyn(__file__)

@app.get('/')
async def index(request):
    return 'hello world'

@app.startup_handler
async def startup_handler():
    print('Starting up...')

@app.shutdown_handler
async def shutdown_handler():
    print('Shutting down...')

app.start(port=8081)

Your operating system

Linux

Your Python version (python --version)

3.12

Your Robyn version

latest

Additional Info

No response

@matt24smith matt24smith added the bug Something isn't working label Sep 16, 2024
@sansyrox
Copy link
Member

@VishnuSanal , can you have a look at this?

@VishnuSanal
Copy link
Contributor

aight, I can reproduce this on my machine too.

@app.shutdown_handler
def shutdown_handler():
    print('Shutting down...')

but, works normally if I remove the async keyword. @matt24smith can you please try it & report back?

@matt24smith
Copy link
Author

Thanks for looking into this!

My use case requires the async keyword, as I'm trying to terminate an async database connection. I can confirm that the non-async case works as expected

@VishnuSanal VishnuSanal linked a pull request Sep 20, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants