-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
Adapt bind_socket to make it usable with multiple processes #1009
Conversation
still WIP I noticed the uvicorn logger message needs to be adapted |
ready now @Kludex ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did my best here. It's a short PR, but I feel like I'm not qualified to approve it yet. I'm going to study some details before having the confidence to do so.
But I hope my current comments make sense.
ready for another review @Kludex |
uvicorn/main.py
Outdated
if config.uds: | ||
os.remove(config.uds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm mistaken, but can't we have a single one of those outside the conditional?
if config.uds: | |
os.remove(config.uds) | |
if config.uds: | |
os.remove(config.uds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can, but it's not right, because we bind inside them. 🤔 Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks simpler yes, I removed occurrences in the basereload and multiprocess shutdown method and put it outside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confident enough now.
But maybe we should wait for the mypy
merge first? Anyway, your call.
the one on config.py ? |
Yeah |
that's a good idea, he put a lot of efforts into it and it would be cruel to have to add that part on top of it ;) |
@@ -395,37 +395,63 @@ def setup_event_loop(self) -> None: | |||
loop_setup() | |||
|
|||
def bind_socket(self) -> socket.socket: | |||
family = socket.AF_INET | |||
addr_format = "%s://%s:%d" | |||
logger_args: List[Union[str, int]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just needed to add this post-merge with master @Kludex
the rest stayed the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I removed the hold button and feel free to merge if still ok with this !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it so weird that the approval is not removed after a commit is pushed. I don't understand the reason behind it.
Anyway, LGTM! :)
* Adapt bind_socket to make it usable with multple processes * Lint * we are in single proc here * Remove socket file also in reloader * Tests * Tests * Remove socket on close * Changed if / else to check uds / fds * Refactored logging inside bind_socket * Added test for fd * Refactored removal of socket * Minimized diff post merge
) * Adapt bind_socket to make it usable with multple processes * Lint * we are in single proc here * Remove socket file also in reloader * Tests * Tests * Remove socket on close * Changed if / else to check uds / fds * Refactored logging inside bind_socket * Added test for fd * Refactored removal of socket * Minimized diff post merge
This makes it possible to use reload and workers flag with uds and fd.
fixes #428 #368 #586 #722