Repository navigation
Conversation
| return | ||
|
|
||
| yield execute_request(request, prepared=prepared) | ||
| yield await asyncio.to_thread(execute_request, request, prepared=prepared) |
There was a problem hiding this comment.
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.
| return | ||
|
|
||
| yield execute_request(request, prepared=prepared) | ||
| yield await asyncio.to_thread(execute_request, request, prepared=prepared) |
There was a problem hiding this comment.
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)?
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