diff options
| author | bd <bdunahu@operationnull.com> | 2025-10-08 15:42:00 -0400 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-10-08 15:42:00 -0400 |
| commit | 5f90a5d7ebfa210ddac031ba4ddaeedb3d041cb3 (patch) | |
| tree | 34ae639edae888d95cdb2fec34f899af88726e0a /nemesis/causal_event_loop.py | |
| parent | 0bd8432b4c6bd3d82c4916e0b6fb173aa7a5ff39 (diff) | |
force assertion failures to abort
Diffstat (limited to 'nemesis/causal_event_loop.py')
| -rw-r--r-- | nemesis/causal_event_loop.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/nemesis/causal_event_loop.py b/nemesis/causal_event_loop.py index f4834fc..3586b18 100644 --- a/nemesis/causal_event_loop.py +++ b/nemesis/causal_event_loop.py @@ -129,7 +129,11 @@ class CausalEventLoop(asyncio.SelectorEventLoop): self._time_entered_coro = self.time() def ping_exit_coro(self): - assert isinstance(self._time_entered_coro, float), f"Tried to exit coro before recorded entry!" + try: + assert isinstance(self._time_entered_coro, float), "Tried to exit coro before recorded entry!" + except AssertionError as e: + print(f"Assertion failed: {e}") + sys.exit(1) self._coro_intervals.add((self._time_entered_coro, self.time())) self._time_entered_coro = None @@ -183,6 +187,7 @@ class CausalEventLoop(asyncio.SelectorEventLoop): pause_timeout = self._pause_buffer[0]._when - curr_time timeout = min(pause_timeout, timeout) if timeout else pause_timeout timeout = max(0, min(timeout, MAXIMUM_SELECT_TIMEOUT)) + timeout = 0 self.collect_ready_events(timeout) for event_list in self._ready_events: @@ -205,8 +210,6 @@ class CausalEventLoop(asyncio.SelectorEventLoop): heapq.heappush(self._pause_buffer, handle) # handle callbacks which can leave pause timeout - # if len(self._pause_buffer) > 100: - # exit(1) heapq.heapify(self._pause_buffer) # print([x._when for x in self._pause_buffer]) while self._pause_buffer: @@ -263,7 +266,11 @@ class CausalEventLoop(asyncio.SelectorEventLoop): pause_time = self._get_pause_time(time_interval) adjusted_start_time = process_start_time - pause_time wait_time = adjusted_start_time - handle._when - assert wait_time >= -0.0001, f"wait time on {_format_handle(handle)} was found to be {wait_time:.4f}!" + try: + assert wait_time >= -0.0001, f"wait time on {_format_handle(handle)} was found to be {wait_time:.4f}!" + except AssertionError as e: + print(f"Assertion failed: {e}") + sys.exit(1) self._completed_coros.append((_format_handle(handle), wait_time)) except Exception: traceback.print_exc() @@ -321,6 +328,7 @@ class CausalEventLoop(asyncio.SelectorEventLoop): handle.time_entered_pause_buffer = curr_time heapq.heappush(self._pause_buffer, handle) + def _get_pause_for_io(self, handle, io_time): time_interval = (handle.register_time, io_time) return self._get_pause_time(time_interval) |
