diff options
| author | bd <bdunahu@operationnull.com> | 2025-10-11 14:05:13 -0400 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-10-11 14:05:13 -0400 |
| commit | 16aa392a3c08c8769cc30bdbc1830a31f9b0808e (patch) | |
| tree | 1f95e02add06a137b2bb7e2ff38a1ef1976e0084 /nemesis/causal_event_loop.py | |
| parent | 5f90a5d7ebfa210ddac031ba4ddaeedb3d041cb3 (diff) | |
try blacklisting _read_from_self from results
Still determining the reason _read_from_self has an abnormally large average callback and biases the results.
Diffstat (limited to 'nemesis/causal_event_loop.py')
| -rw-r--r-- | nemesis/causal_event_loop.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/nemesis/causal_event_loop.py b/nemesis/causal_event_loop.py index 3586b18..2fe8435 100644 --- a/nemesis/causal_event_loop.py +++ b/nemesis/causal_event_loop.py @@ -74,12 +74,12 @@ class TimeAwareMixin: def create_subclass(base_class): - class NewSubclass(base_class, TimeAwareMixin): + class CausalHandle(base_class, TimeAwareMixin): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) TimeAwareMixin.__init__(self) - return NewSubclass + return CausalHandle # make all the subclasses inherit from TimeAwareHandle as well @@ -271,7 +271,8 @@ class CausalEventLoop(asyncio.SelectorEventLoop): except AssertionError as e: print(f"Assertion failed: {e}") sys.exit(1) - self._completed_coros.append((_format_handle(handle), wait_time)) + if not self._is_blacklisted(handle): + self._completed_coros.append((_format_handle(handle), wait_time)) except Exception: traceback.print_exc() finally: @@ -331,7 +332,15 @@ class CausalEventLoop(asyncio.SelectorEventLoop): def _get_pause_for_io(self, handle, io_time): time_interval = (handle.register_time, io_time) - return self._get_pause_time(time_interval) + p_time = self._get_pause_time(time_interval) + + try: + assert p_time >= 0, f"calculated pause time on {_format_handle(handle)} was found to be {p_time:.4f}!" + except AssertionError as e: + print(f"Assertion failed: {e}") + sys.exit(1) + + return p_time def _get_pause_for_pause_time(self, handle, exit_time): time_interval = (handle.time_entered_pause_buffer, exit_time) @@ -361,6 +370,17 @@ class CausalEventLoop(asyncio.SelectorEventLoop): overlap_end = min(a_end, b_end) return overlap_end - overlap_start + def _is_blacklisted(self, handle): + blacklist = ['_read_from_self'] + cb = handle._callback + if isinstance(getattr(cb, '__self__', None), asyncio.tasks.Task): + if cb.__self__.get_coro().__name__ in blacklist: + return True + else: + if getattr(cb, '__name__', None) in blacklist: + return True + return False + class CausalEventLoopPolicy(asyncio.DefaultEventLoopPolicy): def new_event_loop(self): |
