diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-10 12:52:25 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-10 12:52:25 -0500 |
commit | 553925a3412b70da85b68cd50729411da5dba73f (patch) | |
tree | 8dbb01f1594d6f1cd1fa42249a26df578910b0ce /coverage/monkey.py | |
parent | 54779fbe4d54a13808f8fee846e6eb626cf40ea2 (diff) | |
download | python-coveragepy-553925a3412b70da85b68cd50729411da5dba73f.tar.gz |
A little clean up of the monkey-patch
Diffstat (limited to 'coverage/monkey.py')
-rw-r--r-- | coverage/monkey.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/coverage/monkey.py b/coverage/monkey.py index 3f78d7d..e7517bf 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() |