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

Fix OSError occurs when workers > 1 #1317 #1443

Closed

Conversation

smitchell6879
Copy link

Should fix OSError

@smitchell6879
Copy link
Author

smitchell6879 commented Apr 6, 2022

I am using python 3.8 with 3 workers on windows 10. Is there any more info on why it failed the test?

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 6, 2022

@smitchell6879
Copy link
Author

linter https://github.com/encode/uvicorn/runs/5849365812?check_suite_focus=true

No log available. So whats my next step?

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 6, 2022

Logs are available...
image

@euri10
Copy link
Member

euri10 commented Apr 6, 2022

linter https://github.com/encode/uvicorn/runs/5849365812?check_suite_focus=true

No log available. So whats my next step?

you can run the lint script in the scripts folder

@smitchell6879
Copy link
Author

linter https://github.com/encode/uvicorn/runs/5849365812?check_suite_focus=true

No log available. So whats my next step?

you can run the lint script in the scripts folder

So I finally figured out how to run the lint script, so it should be good now. Sorry for the my ignorance.

Comment on lines +12 to +13
"The --reload flag should not be \
used in production on Windows."
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"The --reload flag should not be \
used in production on Windows."
"The --reload flag should not be "
"used in production on Windows."

@Kludex Kludex requested a review from graingert April 7, 2022 08:21
@smitchell6879
Copy link
Author

Is there something else I need to fix or does this look good?

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 12, 2022

I'm going to check this tonight.

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 12, 2022

This is basically a revert of #1257, which was in place to solve other issues...

@euri10
Copy link
Member

euri10 commented Apr 14, 2022

ok this one I dont get it, what is the purpose of the PR, please describe the issue

@smitchell6879
Copy link
Author

ok this one I dont get it, what is the purpose of the PR, please describe the issue

The issue is #1317. On windows when running multiple workers without reload true you would get a oserror. By writing it this way you still provide the warning if reload is true but you no longer get the oserror.

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 14, 2022

This is basically a revert of #1257, which was in place to solve other issues...

Is my statement false?

@smitchell6879
Copy link
Author

smitchell6879 commented Apr 14, 2022

I am assuming no your statement is not false but I am unsure of what issues the change fixed when it also created a new issue. I am currently home sick when I feel better I will dig into the code more to try to figure out the issue that this change fixed and see if I can recreate it.

@Kludex
Copy link
Sponsor Member

Kludex commented Apr 14, 2022

Hope you get better soon. 😟

@smitchell6879
Copy link
Author

smitchell6879 commented Apr 18, 2022

So I have linked the log to show the errors I am getting without the above change. I am using a custom logger so [Backend] is actually the uvicorn channel. https://pastebin.com/cXQuG3SH
Reviewing the code it seems to me without this change you are not setting the asyncio.set_event_loop_policy at all unless you have the reload parameter set to True in which case it shouldn't matter as much because you go back you only 1 worker. As you see in the paste bin I have reload set to False and workers set to 5 I forgot to add the python version which is 3.8 .
I am not going to act like I full understand asyncio.set_event_loop_policy But after digging around the net I did find "tornadoweb/tornado#2608" so I have updated to their teams fix. This does not give me any errors.

@euri10
Copy link
Member

euri10 commented Apr 20, 2022

I think #1454 is a better alternative, ymmv

@smitchell6879
Copy link
Author

Thats cool too as long as it fixes the issue.

@smitchell6879
Copy link
Author

Has anyone had a chance to review either of these and decide which fix you prefer?

@smitchell6879
Copy link
Author

Any chance for a update on this issue?

@Kludex
Copy link
Sponsor Member

Kludex commented May 5, 2022

This solution reverts previous changes. As mentioned on #1220 (comment), we should use the ProactorEventLoop whenever is possible. The case on which we don't want to use it is when we have either reload being True or the value of workers being higher than 1.

The ideal solution here would be to just make that check. I think we can even check if we're running on a child process instead of passing the reload/workers around.

As a note, the warning saying that reload should not be used in production is misplaced. It's not because we got to that point that we are in production. The warning should be removed.

In any case, I'll be closing this because of what I said on the first paragraph. Let's continue this on #1454 . Thanks for the efforts here @smitchell6879 ! 🙇

References:

@Kludex Kludex closed this May 5, 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