Skip to content

Commit a723d85

Browse files
committed
use warning instead of printing message when restoring more than patching in a thread
1 parent ad5aa63 commit a723d85

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

mkl_umath/src/_patch_numpy.pyx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,12 @@ class _GlobalPatch:
189189
with self._lock:
190190
local_count = getattr(self._tls, "local_count", 0)
191191
if local_count <= 0:
192-
if verbose:
193-
print(
194-
"Warning: restore_numpy_umath called more times than "
195-
"patch_numpy_umath in this thread."
196-
)
192+
warnings.warn(
193+
"restore_numpy_umath called more times than "
194+
"patch_numpy_umath in this thread.",
195+
RuntimeWarning,
196+
stacklevel=1, # Cython does not add a stacklevel
197+
)
197198
return
198199

199200
next_patch_count = self._patch_count - 1

0 commit comments

Comments
 (0)