summaryrefslogtreecommitdiff
path: root/coverage/multiproc.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/multiproc.py')
-rw-r--r--coverage/multiproc.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/coverage/multiproc.py b/coverage/multiproc.py
index fe837318..bbc88fbe 100644
--- a/coverage/multiproc.py
+++ b/coverage/multiproc.py
@@ -6,19 +6,16 @@
import multiprocessing
import multiprocessing.process
import os
-import sys
+from coverage import env
from coverage.misc import contract
# An attribute that will be set on the module to indicate that it has been
# monkey-patched.
PATCHED_MARKER = "_coverage$patched"
-# The environment variable that specifies the rcfile for subprocesses.
-COVERAGE_RCFILE_ENV = "_COVERAGE_RCFILE"
-
-if sys.version_info >= (3, 4):
+if env.PYVERSION >= (3, 4):
OriginalProcess = multiprocessing.process.BaseProcess
else:
OriginalProcess = multiprocessing.Process
@@ -31,10 +28,10 @@ class ProcessWithCoverage(OriginalProcess):
def _bootstrap(self):
"""Wrapper around _bootstrap to start coverage."""
from coverage import Coverage # avoid circular import
- rcfile = os.environ[COVERAGE_RCFILE_ENV]
- cov = Coverage(data_suffix=True, config_file=rcfile)
+ cov = Coverage(data_suffix=True)
+ cov._warn_preimported_source = False
cov.start()
- debug = cov.debug
+ debug = cov._debug
try:
if debug.should("multiproc"):
debug.write("Calling multiprocessing bootstrap")
@@ -73,14 +70,14 @@ def patch_multiprocessing(rcfile):
if hasattr(multiprocessing, PATCHED_MARKER):
return
- if sys.version_info >= (3, 4):
+ if env.PYVERSION >= (3, 4):
OriginalProcess._bootstrap = ProcessWithCoverage._bootstrap
else:
multiprocessing.Process = ProcessWithCoverage
# Set the value in ProcessWithCoverage that will be pickled into the child
# process.
- os.environ[COVERAGE_RCFILE_ENV] = rcfile
+ os.environ["COVERAGE_RCFILE"] = rcfile
# When spawning processes rather than forking them, we have no state in the
# new process. We sneak in there with a Stowaway: we stuff one of our own