Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/mac_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
if: ${{ needs.call-check-pr-status.outputs.should_continue == 'true' }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build_type: [debug, release]
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ class GlobalThreadManager:
_instance: "GlobalThreadManager | None" = None
_lock: threading.Lock = threading.Lock()

_ref_count: int
_main_thread: threading.Thread | None
_main_loop: asyncio.AbstractEventLoop | None
_stop_event: asyncio.Event
_loop_ready_event: threading.Event

def __new__(cls):
if cls._instance is None:
with cls._lock:
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance._initialized = False
instance = super().__new__(cls)
instance._ref_count = 0
instance._main_thread = None
instance._main_loop = None
instance._stop_event = asyncio.Event()
instance._loop_ready_event = threading.Event()
# Publish only after initialization, while holding the lock.
cls._instance = instance
return cls._instance

def __init__(self):
if self._initialized:
return

self._ref_count: int = 0
self._main_thread: threading.Thread | None = None
self._main_loop: asyncio.AbstractEventLoop | None = None
self._stop_event: asyncio.Event = asyncio.Event()
self._loop_ready_event: threading.Event = threading.Event()
self._initialized: bool = True

def reset(self):
with self._lock:
self._ref_count = 0
self._main_thread = None
self._main_loop = None
self._stop_event = asyncio.Event()
self._loop_ready_event = threading.Event()
self._initialized = True

def get_or_start_thread(
self, ten_env: "TenEnv"
Expand Down
Loading