Skip to content

Commit 0205d39

Browse files
📝 Update docstring for syncify(), fix name of parameter raise_sync_error (remove unused parameter name check_called_from_async) (#113)
Co-authored-by: Sebastián RamĂ­rez <[email protected]>
1 parent 3b6b903 commit 0205d39

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎asyncer/_main.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ def syncify(
256256
By default this is expected to be used from a worker thread. For example inside
257257
some function passed to `asyncify()`.
258258
259-
But if you set `check_called_from_async` to `False`, you can also use this function
259+
But if you set `raise_sync_error` to `False`, you can also use this function
260260
in a non-async context: without an async event loop. For example, from a
261261
blocking/regular function called at the top level of a Python file. In that case,
262262
if it is not being called from inside a worker thread started from an async context
263263
(e.g. this is not called from a function that was called with `asyncify()`) it will
264264
run `async_function` in a new async event loop with `anyio.run()`.
265265
266-
This functionality with `check_called_from_async` is there only to allow using
266+
This functionality with `raise_sync_error` is there only to allow using
267267
`syncify()` in codebases that are used by async code in some cases and by blocking
268268
code in others. For example, during migrations from blocking code to async code.
269269
@@ -285,7 +285,9 @@ async def do_work(arg1, arg2, kwarg1="", kwarg2=""):
285285
286286
`async_function`: an async function to be called in the main thread, in the async
287287
event loop
288-
`check_called_from_async`: If set to `False`
288+
`raise_sync_error`: If set to `False`, when used in a non-async context (without
289+
an async event loop), it will run `async_function` in a new async event loop,
290+
instead of raising an exception.
289291
290292
## Return
291293

0 commit comments

Comments
 (0)