From bd3059f01bdf9b4c5b9fb61417296dc70cbe3b13 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 2 Jan 2021 21:35:13 -0500 Subject: [PATCH] Allow for error bypass --- tractor/_state.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tractor/_state.py b/tractor/_state.py index 37e6a1f..5f42415 100644 --- a/tractor/_state.py +++ b/tractor/_state.py @@ -15,11 +15,12 @@ _runtime_vars: Dict[str, Any] = { } -def current_actor() -> 'Actor': # type: ignore +def current_actor(err_on_no_runtime: bool = True) -> 'Actor': # type: ignore """Get the process-local actor instance. """ - if _current_actor is None: + if _current_actor is None and err_on_no_runtime: raise RuntimeError("No local actor has been initialized yet") + return _current_actor