MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / call_on_scheduler

Method call_on_scheduler

examples/server/server.py:15491–15508  ·  view source on GitHub ↗
(self, callback: Callable[[], Any])

Source from the content-addressed store, hash-verified

15489 self.condition.notify_all()
15490
15491 def call_on_scheduler(self, callback: Callable[[], Any]) -> Any:
15492 result_box: Dict[str, Any] = {}
15493 error_box: Dict[str, BaseException] = {}
15494 done = threading.Event()
15495
15496 def run_callback() -> None:
15497 try:
15498 result_box["result"] = callback()
15499 except BaseException as exc: # noqa: BLE001
15500 error_box["error"] = exc
15501 finally:
15502 done.set()
15503
15504 self.enqueue(run_callback)
15505 done.wait()
15506 if "error" in error_box:
15507 raise error_box["error"]
15508 return result_box.get("result")
15509
15510 def call_on_idle_scheduler(self, callback: Callable[[], Any]) -> Any:
15511 result_box: Dict[str, Any] = {}

Callers 1

Calls 1

enqueueMethod · 0.95

Tested by

no test coverage detected