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

Fix event loop handling for Windows platform in compose_up function #1149

Merged
merged 3 commits into from
Mar 1, 2025

Conversation

AlexandreAANP
Copy link

Hi,
I tried to run podman-compose on Windows and always break the script because of NotImplementedError in asyncio/events.
After a fast search, I noted that Windows doesn't have support for signals, and I found a code solution to solve this issue in this stack overflow link: https://stackoverflow.com/questions/58014623/python-asyncio-notimplementederror

I added an if condition to check if it's a Windows system or not, not sure if the best way to compare, but it works.

@p12tic
Copy link
Collaborator

p12tic commented Feb 26, 2025

Reading through the stackoverflow post and linked pages, seems like WindowsSelectorEventLoopPolicy was needed for aio-dns library which we don't use.

Maybe it is enough for podman-compose to simply not call add_signal_handler and not touch the event loop policy?

@AlexandreAANP
Copy link
Author

AlexandreAANP commented Feb 26, 2025

I investigated further and found that the default event loop policy on Windows is WindowsProactorEventLoop for Python versions 3.8 and above. This policy is more efficient than the manually set selector-based loop.

Since Python versions below 3.8 already default to WindowsSelectorEventLoop, explicitly setting it is unnecessary and may cause compatibility issues across different versions. Therefore, it should be removed.
My last commit fixed that.
Thank you.

@p12tic
Copy link
Collaborator

p12tic commented Feb 26, 2025

Looks good, please add release note in newsfragments directory.

@AlexandreAANP
Copy link
Author

Sorry, I'm kind of new to project contribution, how should be the news fragment type for this modification?

@p12tic
Copy link
Collaborator

p12tic commented Feb 26, 2025

bugfix ? Fixed NotImplementedError in case script is interrupted on Windows or something like that.

We need to figure out how to catch ctrl-c and cancel tasks on windows though, but this can be sometime in the future.

@AlexandreAANP
Copy link
Author

Sorry, for these extra commits, I was trying to sign off them to pass all the checks.
Unfortunately, this is still breaking the pipeline.
Sorry for this newbie mistake.

@p12tic
Copy link
Collaborator

p12tic commented Feb 28, 2025

@AlexandreAANP No problems at all, I have been newbie some time ago as well :-)

What you need to do is to use interactive rebase to combine the commits into one. Then you would need to amend the commit to adjust its commit message so that the signed-off-by line can be added.

Here is tutorial on how to use amend and rebase https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history

@AlexandreAANP AlexandreAANP force-pushed the fix/windows-asyncio-loop branch from 9b7bfaa to fd40133 Compare February 28, 2025 13:39
@p12tic
Copy link
Collaborator

p12tic commented Mar 1, 2025

Thanks!

@p12tic p12tic merged commit a54f0fa into containers:main Mar 1, 2025
8 checks passed
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.

2 participants