26 original_bootstrap = OriginalProcess._bootstrap |
26 original_bootstrap = OriginalProcess._bootstrap |
27 |
27 |
28 class ProcessWithCoverage(OriginalProcess): |
28 class ProcessWithCoverage(OriginalProcess): |
29 """A replacement for multiprocess.Process that starts coverage.""" |
29 """A replacement for multiprocess.Process that starts coverage.""" |
30 |
30 |
31 def _bootstrap(self): |
31 def _bootstrap(self, *args, **kwargs): # pylint: disable=arguments-differ |
32 """Wrapper around _bootstrap to start coverage.""" |
32 """Wrapper around _bootstrap to start coverage.""" |
33 from coverage import Coverage # avoid circular import |
33 from coverage import Coverage # avoid circular import |
34 rcfile = os.environ[COVERAGE_RCFILE_ENV] |
34 rcfile = os.environ[COVERAGE_RCFILE_ENV] |
35 cov = Coverage(data_suffix=True, config_file=rcfile) |
35 cov = Coverage(data_suffix=True, config_file=rcfile) |
36 cov.start() |
36 cov.start() |
37 debug = cov.debug |
37 debug = cov.debug |
38 try: |
38 try: |
39 if debug.should("multiproc"): |
39 if debug.should("multiproc"): |
40 debug.write("Calling multiprocessing bootstrap") |
40 debug.write("Calling multiprocessing bootstrap") |
41 return original_bootstrap(self) |
41 return original_bootstrap(self, *args, **kwargs) |
42 finally: |
42 finally: |
43 if debug.should("multiproc"): |
43 if debug.should("multiproc"): |
44 debug.write("Finished multiprocessing bootstrap") |
44 debug.write("Finished multiprocessing bootstrap") |
45 cov.stop() |
45 cov.stop() |
46 cov.save() |
46 cov.save() |