Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion tests/test_singlenodeexecutor_noblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from executorlib import SingleNodeExecutor
from executorlib.standalone.serialize import cloudpickle_register
from executorlib.standalone.interactive.communication import ExecutorlibSocketError


def calc(i):
Expand All @@ -22,6 +23,11 @@ def init_function():
return {"a": 1, "b": 2}


def exit_funct():
import sys
sys.exit()


class TestExecutorBackend(unittest.TestCase):
def test_meta_executor_serial_with_dependencies(self):
with SingleNodeExecutor(
Expand Down Expand Up @@ -139,4 +145,24 @@ def test_block_allocation_False_two_workers(self):
) as exe:
f1_worker_id = exe.submit(get_worker_id, resource_dict={})
f2_worker_id = exe.submit(get_worker_id, resource_dict={})
self.assertEqual(sum([f1_worker_id.result(), f2_worker_id.result()]), 0)
self.assertEqual(sum([f1_worker_id.result(), f2_worker_id.result()]), 0)


class TestFunctionCrashes(unittest.TestCase):
def test_single_node_executor(self):
with self.assertRaises(ExecutorlibSocketError):
with SingleNodeExecutor(max_workers=2) as exe:
f = exe.submit(exit_funct)
print(f.result())

def test_single_node_executor_block_allocation(self):
with self.assertRaises(ExecutorlibSocketError):
with SingleNodeExecutor(max_workers=2, block_allocation=True) as exe:
f = exe.submit(exit_funct)
print(f.result())

def test_single_node_executor_init_function(self):
with self.assertRaises(ExecutorlibSocketError):
with SingleNodeExecutor(max_workers=2, init_function=exit_funct, block_allocation=True) as exe:
f = exe.submit(sum, [1, 1])
print(f.result())
Loading