Replies: 2 comments 10 replies
-
Why are you not using |
Beta Was this translation helpful? Give feedback.
2 replies
-
I would start with some refactoring. Run the async runtime in your main task. That way you can use anyio's native thread support. I'd recommend not to directly use Also, you should your subscription using an
(thus your |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My goal is to make async code available to sync code, where the async code is running in a different thread, because I will have async tasks witch run in the background. Therefore, I have two threads. One where the async event loop runs (
event_loop_thread
) and the other one for the blocking world (MainThread
).I chose to use the
BlockingPortal
for that. Here is the code how I do the setupNow I can call
run_async
with an async function and everything works. Except, when I have aTaskGroup
with background tasks. Imagine the following example. I have aSubscription
object that starts arenew
task after subscribing. In order to test this out, I created the following scriptBut after the first
run_async
call, I get aRuntimeError: Attempted to exit a cancel scope that isn't the current tasks's current cancel scope
.Is there a solution to my problem?
Beta Was this translation helpful? Give feedback.
All reactions