Skip to content

Commit 2bd3e58

Browse files
committed
fixup: drain executor at exit and relax non-blocking test timing margin
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent c6daee2 commit 2bd3e58

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

openfeature/_event_support.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import atexit
34
import threading
45
import typing
56
from collections import defaultdict
@@ -20,6 +21,7 @@
2021

2122
logger = getLogger("openfeature")
2223
_event_executor = ThreadPoolExecutor(thread_name_prefix="openfeature-event-handler")
24+
atexit.register(_event_executor.shutdown, wait=True)
2325

2426
_global_lock = threading.RLock()
2527
_global_handlers: dict[ProviderEvent, list[EventHandler]] = defaultdict(list)

tests/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ def slow_handler(details):
643643

644644
# Then
645645
assert handler_started.wait(timeout=1)
646-
assert elapsed < 0.2
646+
# emit must return well before the handler's blocking wait (1s) would finish
647+
assert elapsed < 0.5
647648
release_handler.set()
648649
assert handler_finished.wait(timeout=1)
649650

0 commit comments

Comments
 (0)