From 09d7405c78855e3b0933a0115979a5ffd5e809b3 Mon Sep 17 00:00:00 2001 From: scaramallion Date: Sat, 27 Jul 2024 17:35:20 +1000 Subject: [PATCH] Fix Windows timer resolution not resetting after Association release (#955) --- pynetdicom/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pynetdicom/utils.py b/pynetdicom/utils.py index 631ed99c7..0871be18d 100644 --- a/pynetdicom/utils.py +++ b/pynetdicom/utils.py @@ -295,6 +295,7 @@ def set_timer_resolution(resolution: Optional[float]) -> Iterator[None]: dll.NtQueryTimerResolution( ctypes.byref(maximum), ctypes.byref(minimum), ctypes.byref(current) ) + original = current.value # Make sure the desired resolution is in the valid range # Timer resolution is in 100 ns units -> 10,000 == 1 ms @@ -307,8 +308,9 @@ def set_timer_resolution(resolution: Optional[float]) -> Iterator[None]: yield None - # Reset the timer resolution - dll.NtSetTimerResolution(resolution, 0, ctypes.byref(current)) + # Reset the timer resolution to the original + dll.NtSetTimerResolution(original, 1, ctypes.byref(current)) + else: yield None