Skip to content

Commit

Permalink
Fix up use of threading events
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartarchibald committed Oct 7, 2020
1 parent 3c997f0 commit a2cc68a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions numba/tests/test_parallel_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,18 +873,26 @@ def test_fork_from_non_main_thread(self):
from numba import njit, prange, objmode
import os
e_running = threading.Event()
e_proceed = threading.Event()
def indirect():
e_running.set()
# wait for forker() to have forked
while not e_proceed.isSet():
pass
def runner():
@njit(parallel=True, nogil=True)
def work():
acc = 0
for x in prange(10):
acc += x
with objmode():
e_running.set()
# wait for forker() to have forked
while not e_proceed.isSet():
pass
indirect()
return acc
work()
def forker():
Expand All @@ -896,8 +904,6 @@ def forker():
# now fork is done signal the runner to proceed to exit
e_proceed.set()
e_running = threading.Event()
e_proceed = threading.Event()
numba_runner = threading.Thread(target=runner,)
fork_runner = threading.Thread(target=forker,)
Expand Down

0 comments on commit a2cc68a

Please sign in to comment.