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

[BUG] Port not being free on app kill #183

Closed
sansyrox opened this issue Apr 5, 2022 · 4 comments · Fixed by #196
Closed

[BUG] Port not being free on app kill #183

sansyrox opened this issue Apr 5, 2022 · 4 comments · Fixed by #196

Comments

@sansyrox
Copy link
Member

sansyrox commented Apr 5, 2022

Description
Run a web server on any port and then press "Ctrl+C".

Then lsof -i tcp:PORT_NUMBER, e.g. lsof -i tcp:5000 for 5000 port.

You will have to manually kill the process.

Expected Behavior
This should not happen.

@Dmourn
Copy link

Dmourn commented May 7, 2022

I noticed this as well as many processes being spawned after press Ctrl+C.
This issue is caused in processpool.py. I thought it may be caused by not calling stop on the event loop (python docs)

I added some print statements and found that the call to run_forever() only triggers after pressing Ctrl+C.

    print("Starting Server")
    server.start(socket, workers)
    print("Calling run_forever() after Ctrl-C") <- This prints
    asyncio.get_event_loop().run_forever()
    print("DEAD CODE run_forever() called ") <- This does not

commenting out the call to run_forever() "fixes" the issue.

@sansyrox
Copy link
Member Author

sansyrox commented May 7, 2022

Hi @Dmourn ,

Thank you for helping with the issue :D

commenting out the call to run_forever() "fixes" the issue.

Calling stop from an exception handler could probably help. But I don't think we should remove run_forever() call.

Another culprit that I can think of is me using unwrap() very heavily in the code.

But thank you for pointing this out! 😄

@Dmourn
Copy link

Dmourn commented May 9, 2022

No problem :) Thanks for making this cool project.

I didn't think that was the solution either. I tried adding stop and os.killpg in quite a few places, but no luck. So maybe the problem is on the rust side.

@sansyrox
Copy link
Member Author

Thanks for making this cool project.

I am glad you like it :D

So maybe the problem is on the rust side.

This is the thing that I will be addressing now. So, should be fixed soon hopefully :D

anandtripathi5 added a commit to anandtripathi5/robyn that referenced this issue May 14, 2022
sansyrox pushed a commit that referenced this issue May 15, 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 a pull request may close this issue.

2 participants