MCPcopy
hub / github.com/InternLM/InternLM / async_executor

Method async_executor

internlm/utils/storage_manager.py:554–564  ·  view source on GitHub ↗

Overview: Execute task in background, then apppend the future instance in _async_stack. Arguments: - fn (:obj:`Callable`): Synchronization fuction.

(self, fn: Callable, *args, **kwargs)

Source from the content-addressed store, hash-verified

552 pass
553
554 def async_executor(self, fn: Callable, *args, **kwargs) -> None:
555 """
556 Overview:
557 Execute task in background, then apppend the future instance in _async_stack.
558 Arguments:
559 - fn (:obj:`Callable`): Synchronization fuction.
560 """
561 if not self._async_loop:
562 raise RuntimeError("Event loop was not initialized, please call this function in async or parallel mode")
563 t = self._async_loop.run_in_executor(self._thread_pool, fn, *args, **kwargs)
564 self._async_stack.append(t)
565
566 def wait(self) -> bool:
567 """Wait for async operations to complete."""

Callers 1

saveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected