Get application worker concurrency during Task init

13 Views Asked by At

I need to do clientside rate limiting for each pool of workers, which means I need to know what the app's concurrency setting is. I'm currently using a custom Task to configure the rate limiting during its init function.

The application's concurrency is set at runtime by the --concurrency flag, not through hardcoded configuration, which means app.conf['worker_concurrency'] is unset.

app.control.inspect().stats() has the right value under [HOSTNAME]['pool']['max-concurrency'], but I'd like to avoid it because it introduces a lot of latency, and, like the concurrency level, I can't locate the current application's hostname, even though it's printed on startup. I shouldn't need to reach out to the entire cluster for the local application's configuration.

Task initialization appears to be pre-fork(?), so billiard reports the current process billiard.process.current_process() is the main process with no children billiard.process.active_children(), and I believe billiard would only be correct when using a process pool.

Parsing argv would work but is totally unreasonable, this information should be available somewhere.

The next best solution may be to use a Worker bootstep start function for setup, but I'm unsure if a task can reach a bootstep data without using globals. Worst case, it could likely be lazy loaded at task start via billiard (assuming that works).

0

There are 0 best solutions below