Initial commit: 2125_GCE project
This commit is contained in:
Regular → Executable
+13
-2
@@ -1,6 +1,9 @@
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Callable, Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SegmentStartEvent:
|
||||
@@ -25,6 +28,7 @@ class ExecutionErrorEvent:
|
||||
class RuntimeEventBus:
|
||||
def __init__(self):
|
||||
self._subscribers: List[Callable] = []
|
||||
self._errors: List[Exception] = []
|
||||
|
||||
def subscribe(self, callback: Callable):
|
||||
self._subscribers.append(callback)
|
||||
@@ -33,5 +37,12 @@ class RuntimeEventBus:
|
||||
for callback in self._subscribers:
|
||||
try:
|
||||
callback(event)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
self._errors.append(e)
|
||||
logger.warning(f"RuntimeEventBus handler error: {e}")
|
||||
|
||||
def get_errors(self) -> List[Exception]:
|
||||
return self._errors.copy()
|
||||
|
||||
def clear_errors(self) -> None:
|
||||
self._errors.clear()
|
||||
|
||||
Reference in New Issue
Block a user