Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistency fixes for test_executor_sequential #566

Merged
merged 1 commit into from
Aug 17, 2023
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
24 changes: 17 additions & 7 deletions test/test_executor_sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ def test_sequential():
ran_jobs.clear()


async def job8():
global ran_jobs
await asyncio.sleep(1)
ran_jobs.append('job8')
class Job8(Job):

def __init__(self):
super().__init__(
identifier='job8', dependencies=set(), task=None,
task_context=None)

async def __call__(self, *args, **kwargs):
global ran_jobs
await asyncio.sleep(3)
ran_jobs.append(self.identifier)


@pytest.fixture
Expand All @@ -174,21 +181,24 @@ def test_sequential_keyboard_interrupt(restore_sigint_handler):
args = None
jobs = OrderedDict()
jobs['one'] = Job1()
jobs['aborted'] = job8
jobs['aborted'] = Job8()
jobs['four'] = Job4()

def delayed_sigint():
time.sleep(0.1)
# Note: a real Ctrl-C would signal the whole process group
os.kill(
os.getpid(),
signal.SIGINT if sys.platform != 'win32' else signal.CTRL_C_EVENT)
if sys.platform == 'win32':
os.kill(os.getpid(), signal.CTRL_C_EVENT)

thread = Thread(target=delayed_sigint)
thread.start()
try:
thread.start()
rc = extension.execute(args, jobs)
assert rc == signal.SIGINT
finally:
thread.join()

assert rc == signal.SIGINT
ran_jobs.clear()