Skip to content

Commit

Permalink
Add PYTEST_PARALLEL_PROCESS
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmcd committed May 23, 2020
1 parent 388e194 commit 868f69d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pytest_parallel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ def run_test(session, item, nextitem):
raise session.Interrupted(session.shouldstop)


def process_with_threads(config, queue, session, tests_per_worker, errors):
def process_with_threads(config, queue, session, tests_per_worker, errors, index):
# This function will be called from subprocesses, forked from the main
# pytest process. First thing we need to do is to change config's value
# so we know we are running as a worker.
config.parallel_worker = True

os.environ["PYTEST_PARALLEL_PROCCESS"] = str(index)

threads = []
for _ in range(tests_per_worker):
thread = ThreadWorker(queue, session, errors)
Expand Down Expand Up @@ -296,8 +298,8 @@ def wait_for_responses_processor():
# This flag will be changed after the worker's fork.
self._config.parallel_worker = False

args = (self._config, queue, session, tests_per_worker, errors)
for _ in range(self.workers):
for i in range(self.workers):
args = (self._config, queue, session, tests_per_worker, errors, i)
process = Process(target=process_with_threads, args=args)
process.start()
processes.append(process)
Expand Down

0 comments on commit 868f69d

Please sign in to comment.