1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Test utilities for dealing with async callables.
Some functions exported from Rust via PyO3/pyo3-asyncio can appear as built-in
functions which are *awaitable* when called, but `inspect.iscoroutinefunction`
returns False.
These helpers let us assert "async-ness" in a robust way without performing any
network I/O.
"""
"""Return True if `fn` behaves like an async function.
Checks `inspect.iscoroutinefunction` first, then falls back to calling the
function and checking `inspect.isawaitable` on the return value.
NOTE: This should be used with arguments that don't trigger real side
effects when merely creating the awaitable.
"""
return True
# Can't probe without arguments
return False
=
# Some PyO3 async exports require an active running event loop even to
# create the awaitable.
return True
# wrong signature; cannot determine
return False
=
# Avoid "coroutine was never awaited" warnings when ret is a coroutine
return