Skip to content
Merged
10 changes: 8 additions & 2 deletions numba/tests/test_sys_monitoring.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dis
import functools
import queue
import sys
import threading
Expand All @@ -11,7 +10,6 @@
from numba.core.serialize import _numba_unpickle


@functools.cache
def generate_usecase():
@jit('int64(int64)',)
def foo(x):
Expand Down Expand Up @@ -285,6 +283,14 @@ def test_disable_from_callback(self):
self.assertEqual(result, self.call_foo_result)
callback.assert_called()
finally:
# It is necessary to restart events that have been disabled. The
# "disabled" state of the `PY_START` event for the tool
# `self.tool_id` "leaks" into subsequent tests. These tests then end
# up failing as events that should trigger do not! It's not really

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            # up failing as events that should trigger do not! It's not really
                                                      ^^^^^^^

you mean that should not trigger?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is trying to convey that "subsequent tests fail as events in them that should be triggered are not being triggered" (this was why the Mock.call_count value was 1 too small, an event that should have triggered did not).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My english parser segfaulted when reading it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to make this comment more clear in 25535b3. Please take a look and see what you think. Thanks!

# clear why this happens, if it is part of the design or a side
# effect of the design, or if this behaviour is simply a bug in
# CPython itself.
sys.monitoring.restart_events()
sys.monitoring.register_callback(tool_id, event, None)
sys.monitoring.set_events(tool_id, NO_EVENTS)
sys.monitoring.free_tool_id(tool_id)
Expand Down