Replies: 2 comments 4 replies
-
@wireboy5 do you mean something like this? async def call_later(delay, async_fn):
await anyio.sleep(delay)
await async_fn()
async with anyio.create_task_group() as tg:
tg.start_soon(call_later, 10, async_fn)
await other_async_fn() not sure how it relates to a thread |
Beta Was this translation helpful? Give feedback.
1 reply
-
It would be easier to suggest solutions if you elaborated on the use case. The code you presented would be better implemented in other ways. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a project where I need to delay the execution of a function, while still running the code following and not blocking. I have tried using
anyio.to_thread.run_sync
to run a synchronous while loop that calls back to anyio like so:This does not work.
anyio.to_thread.run_sync
still blocks for the specified time. Why would this be? Is there a way to make this work that is not documented yet?Beta Was this translation helpful? Give feedback.
All reactions