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

Enable cltr-c tests on windows #2412

Merged

Conversation

freider
Copy link
Contributor

@freider freider commented Oct 27, 2024

We were previously not testing Ctrl-C behavior on windows since SIGINT doesn't work and the python standard library makes it tricky to send CTRL_C_EVENT to a subprocess.

This was worked around in recent #2322 and this patch generalizes that fix and reactivates our CLI tests for windows

@freider freider changed the base branch from main to freider/map-traceback-barf October 27, 2024 11:55
@freider
Copy link
Contributor Author

freider commented Oct 27, 2024

FAILED test/cli_test.py::test_keyboard_interrupt_during_app_load - subprocess.TimeoutExpired: Command '['C:\\hostedtoolcache\\windows\\Python\\3.10.11\\x64\\python.exe', '-m', 'modal', 'run', 'D:\\a\\modal-client\\modal-client\\test\\supports\\hello.py::hello']' timed out after 5 seconds
I guess I'll have to bring out the ol' windows laptop again 😿 🪟

@freider
Copy link
Contributor Author

freider commented Oct 28, 2024

Turns out Ctrl-C doesn't actually work on the windows client in many cases, since synchronicity (though actually the underlying concurrent.futures.Future) doesn't support aborting a long running blocking call. Attempt at fix in modal-labs/synchronicity#179

raise KeyboardInterrupt()

original_sigint_handler = None
def run_async_gen(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pulled this out of the Runner here and made it use the identical Runner implementation from synchronicity itself instead

@@ -27,7 +27,7 @@ install_requires =
grpclib==0.4.7
protobuf>=3.19,<5.0,!=4.24.0
rich>=12.0.0
synchronicity~=0.8.3
synchronicity~=0.9.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version upgrade the actual windows issues

@@ -54,3 +55,25 @@ def deploy_app_externally(
print(f"Deploying app failed!\n### stdout ###\n{stdout_s}\n### stderr ###\n{stderr_s}")
raise Exception("Test helper failed to deploy app")
return stdout_s


class PopenWithCtrlC(subprocess.Popen):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an identical helper in the tests of synchronicity, but it's not part of the synchronicity package, so we can't reuse it here

@freider
Copy link
Contributor Author

freider commented Oct 31, 2024

@prbot approve

Copy link

@modal-pr-review-automation modal-pr-review-automation bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please request a reviewer to follow up with a post-merge review.

@freider freider merged commit 9d1fc38 into freider/map-traceback-barf Oct 31, 2024
19 checks passed
@freider freider deleted the freider/enable-cltr-c-tests-on-windows branch October 31, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant