Skip to content

Conversation

@dkang-quora
Copy link
Contributor

@dkang-quora dkang-quora commented Jul 18, 2025

This parameter allows the synchronous calls in asyncio mode. It's used to migrate the existing synchronous function to @asynq() in an incremental way.

@asynq(allow_sync_call=False)
def fn(..): ...

with AsyncioMode():
    fn()

Test:

>>> import asynq
>>> asynq.asynq_to_async._asyncio_mode.set(True)
<Token var=<ContextVar name='asyncio_mode' default=False at 0x7f7170e1de90> at 0x7f7171966d40>
>>> @asynq.asynq(allow_sync_call=True)
... def fn(): ...
... 
>>> fn()
asyncio mode does not support synchronous calls: <function fn at 0x7f7170da6d40> at <stdin>

@dkang-quora dkang-quora merged commit 214bb72 into quora:master Jul 18, 2025
9 checks passed
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.

1 participant