Skip to content

fix(queue): honor concurrency for dev function calls - #17

Open
KAJdev wants to merge 3 commits into
mainfrom
zeke/con-2182-flash-20-g-023-dev-ignores-max_concurrency
Open

KAJdev wants to merge 3 commits into
mainfrom
zeke/con-2182-flash-20-g-023-dev-ignores-max_concurrency

Conversation

@KAJdev

@KAJdev KAJdev commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

With @app.queue(max_concurrency=4), four async calls that each sleep for 15 seconds could take roughly a minute on one dev worker. Running a function blocked the worker’s event loop, so it could not start the other calls.

Dev queue function calls run off the worker’s event loop, allowing sync and async functions to overlap within the configured concurrency limit. Each response captures its own stdout, including when another concurrent call fails, while prints also reach the worker logs.

Fixes CON-2182

@KAJdev
KAJdev requested review from deanq and justinwlin November 19, 2026 22:46
Comment thread src/runpod_sdk_runtime/queue/worker.py Resolved
Comment thread src/runpod_sdk_runtime/queue/worker.py Resolved
Comment thread src/runpod_sdk_runtime/queue/worker.py Outdated
return

yield execute_request(request, prepared=prepared)
yield await asyncio.to_thread(execute_request, request, prepared=prepared)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

resolve_request(request) runs before the thread hop. It does the apt and pip installs (blocking subprocess.run) and execs the module code, so module-level setup like model = load_model() runs on the loop for every request. For a function with dependencies=[...], four concurrent calls each run pip one after another on the loop, a second or more each even when installed, and ping, heartbeat and job-take block meanwhile. The 4x15s example in the tests passes because its source has no deps and no top-level work. Is leaving this on the loop intentional for this PR? Moving it into the thread would need locks, since _apt_updated and _materialize_source are check-then-set and concurrent pip runs can race. If it stays, a line in the description about what is and is not covered would help.

Comment thread src/runpod_sdk_runtime/queue/worker.py Outdated
return

yield execute_request(request, prepared=prepared)
yield await asyncio.to_thread(execute_request, request, prepared=prepared)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The sync generator and async generator branches are unchanged, so def gen(): time.sleep(15); yield 1 with max_concurrency=4 still takes about 60s and blocks heartbeats, same as before. The description says sync and async functions now overlap, which reads as covering all of them. Do you want to scope the description to non-generator functions, or drive the sync generator from the executor (pull next() through run_in_executor)?

@KAJdev
KAJdev requested a review from deanq November 20, 2026 02:45

This branch has not been deployed

No deployments
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.

2 participants