fix(runtime): set CURRENT_RUNTIME in Runtime::run() - #952
Closed
paddor wants to merge 2 commits into
Closed
Conversation
PollFd implements futures_util::AsyncRead and AsyncWrite, which require the "io" feature on futures-util. Without it, compio-runtime fails to compile.
Runtime::run() calls executor.tick() without self.enter(), so CURRENT_RUNTIME is not set. If a task polled or dropped during tick() accesses the runtime (e.g. TimerFuture::poll or TimerFuture::drop calling Runtime::with_current()), it panics with "not in a compio runtime". This affects any code that calls run() outside block_on(), such as custom event loops or manual executor drain after block_on(). Wrap the tick() call in self.enter() so the thread-local is set, matching what block_on() already does.
paddor
force-pushed
the
fix/runtime-run-tls
branch
from
June 14, 2026 20:30
e765da8 to
1cc45d2
Compare
Member
|
This is intended. |
Contributor
Author
|
Good to know. Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Runtime::run()callsself.executor.tick()withoutself.enter(), soCURRENT_RUNTIMEis not set during task executiontick()that callsRuntime::with_current()(e.g.TimerFuture::poll,TimerFuture::drop) panics with "not in a compio runtime"tick()inself.enter()to match whatblock_on()andRuntime::drop()already doblock_on()returns and ticks it viarun()futures-util"io"feature needed forPollFd'sAsyncRead/AsyncWriteimpls (same as fix(runtime): features offutures-util#951)