MCPcopy Index your code
hub / github.com/dabeaz/python-cookbook / wrapper

Function wrapper

src/7/inlining_callback_functions/example.py:23–33  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

21def inlined_async(func):
22 @wraps(func)
23 def wrapper(*args):
24 f = func(*args)
25 result_queue = Queue()
26 result_queue.put(None)
27 while True:
28 result = result_queue.get()
29 try:
30 a = f.send(result)
31 apply_async(a.func, a.args, callback=result_queue.put)
32 except StopIteration:
33 break
34 return wrapper
35
36# Sample use

Callers

nothing calls this directly

Calls 5

apply_asyncFunction · 0.70
funcFunction · 0.50
putMethod · 0.45
getMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected