summaryrefslogtreecommitdiff
path: root/coverage/monkey.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-01-10 12:52:25 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-01-10 12:52:25 -0500
commite658fb3268ca192e5f329314bbb4fb3f62652e30 (patch)
tree80c5456734e116019cfff33a61ab87213d569530 /coverage/monkey.py
parent7865e5067d30c98f280ad06175b26c93508783c5 (diff)
downloadpython-coveragepy-git-e658fb3268ca192e5f329314bbb4fb3f62652e30.tar.gz
A little clean up of the monkey-patch
Diffstat (limited to 'coverage/monkey.py')
-rw-r--r--coverage/monkey.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/coverage/monkey.py b/coverage/monkey.py
index 3f78d7dc..e7517bf6 100644
--- a/coverage/monkey.py
+++ b/coverage/monkey.py
@@ -33,6 +33,15 @@ class ProcessWithCoverage(klass):
cov.save()
+class Stowaway(object):
+ """An object to pickle, so when it is unpickled, it can apply the monkey-patch."""
+ def __getstate__(self):
+ return {}
+
+ def __setstate__(self, state_unused):
+ patch_multiprocessing()
+
+
def patch_multiprocessing():
"""Monkey-patch the multiprocessing module.
@@ -55,7 +64,7 @@ def patch_multiprocessing():
# re-applies the monkey-patch.
# Windows only spawns, so this is needed to keep Windows working.
try:
- from multiprocessing import spawn
+ from multiprocessing import spawn # pylint: disable=no-name-in-module
original_get_preparation_data = spawn.get_preparation_data
except (ImportError, AttributeError):
pass
@@ -69,12 +78,3 @@ def patch_multiprocessing():
spawn.get_preparation_data = get_preparation_data_with_stowaway
setattr(multiprocessing, PATCHED_MARKER, True)
-
-
-class Stowaway(object):
- """An object to pickle, so when it is unpickled, it can apply the monkey-patch."""
- def __getstate__(self):
- return {}
-
- def __setstate__(self, state):
- patch_multiprocessing()