Skip to content

Commit

Permalink
fix last test
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Jul 31, 2023
1 parent c431b88 commit c7610fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion pympipool/shared/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ def bootup(self, command_lst):
self._future = self._executor.submit(jobspec)

def shutdown(self, wait=True):
self._executor.shutdown(wait=wait)
if self.poll():
self._future.cancel()
# The flux future objects are not instantly updated,
# still showing running after cancel was called,
# so we wait until the execution is completed.
self._future.result()

def poll(self):
return self._future is not None and not self._future.done()
Expand Down
16 changes: 8 additions & 8 deletions tests/test_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class TestFlux(unittest.TestCase):
def setUp(self):
self.executor = FluxExecutor()

# def test_flux_executor(self):
# with PyFluxExecutor(max_workers=2, executor=self.executor) as exe:
# fs_1 = exe.submit(calc, 1)
# fs_2 = exe.submit(calc, 2)
# self.assertEqual(fs_1.result(), 1)
# self.assertEqual(fs_2.result(), 2)
# self.assertTrue(fs_1.done())
# self.assertTrue(fs_2.done())
def test_flux_executor(self):
with PyFluxExecutor(max_workers=2, executor=self.executor) as exe:
fs_1 = exe.submit(calc, 1)
fs_2 = exe.submit(calc, 2)
self.assertEqual(fs_1.result(), 1)
self.assertEqual(fs_2.result(), 2)
self.assertTrue(fs_1.done())
self.assertTrue(fs_2.done())

def test_single_task(self):
with SingleTaskExecutor(cores=2, executor=self.executor) as p:
Expand Down

0 comments on commit c7610fd

Please sign in to comment.