_source_traceback[-1] if not coroutines.iscoroutine(coro): self._log_destroy_pending = False raise TypeError(f"a coroutine was expected, got {coro!r}") if name is None: self._name = f'Task-{_task_name_counter()}' else: self._name = str(name) self._must_cancel = False self....
__init__(loop=loop) # Task必须用协程作为参数进行实例化 if not coroutines.iscoroutine(coro): raise TypeError(f"a coroutine was expected, got {coro!r}") #设置一些类的属性 self._must_cancel = False self._fut_waiter = None self._coro = coro self._context = contextvars.copy_context() ...
"""A coroutine wrapped in a Future.""" def __init__(self, coro, *, loop=None, name=None): super().__init__(loop=loop) # Task必须用协程作为参数进行实例化 if not coroutines.iscoroutine(coro): raise TypeError(f"a coroutine was expected, got {coro!r}") #设置一些类的属性 self._...
def run(main, *, debug=False): if events._get_running_loop() is not None: raise RuntimeError( "asyncio.run() cannot be called from a running event loop") if not coroutines.iscoroutine(main): raise ValueError("a coroutine was expected, got {!r}".format(main)) loop = events.new_...
defrun(main, *, debug=False):ifevents._get_running_loop()isnotNone:# 获取当前是否含有 loopraiseRuntimeError("asyncio.run() cannot be called from a running event loop")ifnotcoroutines.iscoroutine(main):# 判断是否是一个 coroutineraiseValueError("a coroutine was expected, got {!r}".format...
if events._get_running_loop() is not None: raise RuntimeError( "asyncio.run() cannot be called from a running event loop") if not coroutines.iscoroutine(main): raise ValueError("a coroutine was expected, got {!r}".format(main)) ...
defrun(main, *, debug=False):ifevents._get_running_loop()isnotNone:raiseRuntimeError("asyncio.run() cannot be called from a running event loop")ifnotcoroutines.iscoroutine(main):raiseValueError("a coroutine was expected, got {!r}".format(main)) ...
coroutine loop.create_unix_connection(protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None) 创建Unix 连接 The socket family will be AF_UNIX; socket type will be SOCK_STREAM. A tuple of (transport, protocol) is returned on success. path is...
If you decide to use the asynchronous client, returns a coroutine resolving to that str. qna_search(query, **kwargs) Performs a search and returns a string containing an answer to the original query. This is optimal to be used as a tool for AI agents. Additional parameters can be ...
We have to wait for the loop to be created in its own thread, otherwise the main thread can race ahead, create the loop first with itsget_loop()call, and then deadlock whenrun_coroutine_threadsafe()is passed a loop that isn't running yet. ...