MCPcopy Index your code
hub / github.com/ipython/ipython / _AsyncIOProxy

Class _AsyncIOProxy

IPython/core/async_helpers.py:64–94  ·  view source on GitHub ↗

Proxy-object for an asyncio Any coroutine methods will be wrapped in event_loop.run_

Source from the content-addressed store, hash-verified

62
63
64class _AsyncIOProxy:
65 """Proxy-object for an asyncio
66
67 Any coroutine methods will be wrapped in event_loop.run_
68 """
69
70 def __init__(self, obj, event_loop):
71 self._obj = obj
72 self._event_loop = event_loop
73
74 def __repr__(self):
75 return f"<_AsyncIOProxy({self._obj!r})>"
76
77 def __getattr__(self, key):
78 attr = getattr(self._obj, key)
79 if inspect.iscoroutinefunction(attr):
80 # if it's a coroutine method,
81 # return a threadsafe wrapper onto the _current_ asyncio loop
82 @wraps(attr)
83 def _wrapped(*args, **kwargs):
84 concurrent_future = asyncio.run_coroutine_threadsafe(
85 attr(*args, **kwargs), self._event_loop
86 )
87 return asyncio.wrap_future(concurrent_future)
88
89 return _wrapped
90 else:
91 return attr
92
93 def __dir__(self):
94 return dir(self._obj)
95
96
97def _curio_runner(coroutine):

Callers 1

shebangMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…