summaryrefslogtreecommitdiff
path: root/coverage/collector.py
diff options
context:
space:
mode:
authorOlivier Grisel <olivier.grisel@ensta.org>2017-08-10 15:52:35 +0200
committerOlivier Grisel <olivier.grisel@ensta.org>2017-08-10 15:52:35 +0200
commitbfee14ab8788b6c97f58308ec5c5b14e57d06cb7 (patch)
tree411decc23e74c8c2534ac34e588b80f1980920cd /coverage/collector.py
parent3bb0bcaeaaa429bd63cce00ef0459f1ba8436c00 (diff)
downloadpython-coveragepy-git-bfee14ab8788b6c97f58308ec5c5b14e57d06cb7.tar.gz
FIX thread-safe Collector.save_data()
--HG-- branch : fix-thread-safety
Diffstat (limited to 'coverage/collector.py')
-rw-r--r--coverage/collector.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index cfdcf402..a318c106 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -374,7 +374,10 @@ class Collector(object):
def abs_file_dict(d):
"""Return a dict like d, but with keys modified by `abs_file`."""
- return dict((abs_file(k), v) for k, v in iitems(d))
+ # The call to list() ensures that the GIL protects the dictionary
+ # iterator against concurrent modifications by tracers running
+ # in other threads.
+ return dict((abs_file(k), v) for k, v in list(iitems(d)))
if self.branch:
covdata.add_arcs(abs_file_dict(self.data))