fix: notify and cancel windows#245
Merged
edwards-aws merged 2 commits intoOpenJobDescription:mainlinefrom Jul 4, 2025
Merged
Conversation
Signed-off-by: Cody Edwards <edwards@amazon.com>
Contributor
There is precedent for this already in the repository, so this is fine. The most well-proven way we know of to run Python as a service is using |
|
jusiskin
approved these changes
Jul 4, 2025
ttblanchard
approved these changes
Jul 4, 2025
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes: aws-deadline/deadline-cloud-worker-agent#490
What was the problem/requirement? (What/Why)
The notify and cancel workflow was failing on Windows because the process sending the signal couldn't attach to the main process console in Session 0
What was the solution? (How)
Create the signal process using LoggingSubprocess, mostly so the signal process can run as the user of the process being cancelled.
What is the impact of this change?
Tasks on Windows can now properly clean up after they've been notified instead of crashing.
How was this change tested?
Ran the cross user tests on Windows in and out of Session 0 (using the service script)
Ran the
sudo_test.shandsudo_test.sh--ldap tests on Ubuntu.Also ran the tests normally on Windows and Ubuntu.
Ran a worker agent locally in session zero using my changes. Created a long sleep job, cancelled it, noticed that it cancelled correctly.
Yes
I'll note that I had to refactor the service tests a bit. I had to call pytest as a module instead of a subprocess. This is because when it ran as subprocess it was running as
python.exeand notpythonservicemanager.exe. This seems to mess with how permissions are inherited. But the tests also now more closely emulate how the library would run as a service in the real world.An unfortunate side effect is that when running as a service
sys.executableevaluates topythonservicemanager.exeinstead ofpython.exe. We usesys.executablea lot in the tests expecting a regular python runtime. So I had to do a refactor so thatpythonservicemanagergets swapped forpythonwhere appropriate.Was this change documented?
Is this a breaking change?
Nope
Does this change impact security?
No
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.