Skip to content

Commit 628c1c5

Browse files
committed
fix: avoid a dict-changed-size error
Windows 3.12 failed occasionally with this error: ``` @panopticon() def stop(self) -> None: """Stop this Tracer.""" if not self.sysmon_on: # In forking situations, we might try to stop when we are not # started. Do nothing in that case. return assert sys_monitoring is not None sys_monitoring.set_events(self.myid, 0) > for code in self.local_event_codes.values(): E RuntimeError: dictionary changed size during iteration ``` By setting self.sysmon_on=False before iteration, we lessen the chance of adding an item to the dict during the iteration.
1 parent 8412054 commit 628c1c5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

coverage/sysmon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ def stop(self) -> None:
251251
return
252252
assert sys_monitoring is not None
253253
sys_monitoring.set_events(self.myid, 0)
254+
self.sysmon_on = False
254255
for code in self.local_event_codes.values():
255256
sys_monitoring.set_local_events(self.myid, code, 0)
256257
self.local_event_codes = {}
257258
sys_monitoring.free_tool_id(self.myid)
258-
self.sysmon_on = False
259259

260260
@panopticon()
261261
def post_fork(self) -> None:

0 commit comments

Comments
 (0)