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

Question: Get worker number from within worker? #54

Closed
lmeyerov opened this issue Feb 27, 2022 · 7 comments
Closed

Question: Get worker number from within worker? #54

lmeyerov opened this issue Feb 27, 2022 · 7 comments

Comments

@lmeyerov
Copy link

Is there a way for a worker to know which # worker it is? In other systems, it is common to have an environment variable (WORKER=0, ...), but I didn't see anything

We're trying to match the CPU + GPU NUMA hierarchy for our workers, and are currently launching our Quart workers as hypercorn -b 0.0.0.0:$PORT --worker-class uvloop ... .

@pgjones
Copy link
Owner

pgjones commented Aug 27, 2022

Does this work?

import os
print(os.getpid())

@lmeyerov
Copy link
Author

No, that is the pid

@pgjones pgjones closed this as completed May 26, 2024
@lmeyerov
Copy link
Author

Thanks -- I saw this is marked closed as "completed", though am not finding it in the docs or closed PRs, is there a feature implementing this I should be looking for?

@pgjones
Copy link
Owner

pgjones commented May 26, 2024

Each Hypercorn worker is a process so the pid can be used to identify which worker at runtime.

@lmeyerov
Copy link
Author

When we launch N workers, we cannot tell which 1 of N, eg, leader. It's fine not implementing, thanks for the clarification.

@pgjones
Copy link
Owner

pgjones commented May 27, 2024

There shouldn't be a leader, as the primary Hypercorn process doesn't handle any requests, rather it manages the other processes.

@lmeyerov
Copy link
Author

lmeyerov commented May 27, 2024

This isn't about what hypercorn needs but the software on top. In our case, it helps to know the worker number.

Again, it is fine the issue is closed, just it hasn't be completed.

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

No branches or pull requests

2 participants