Skip to content

Bugfix/cli tests win fix event loop freeze#4961

Open
xmkg wants to merge 4 commits into
mainfrom
bugfix/cli-tests-win-fix-event-loop-freeze
Open

Bugfix/cli tests win fix event loop freeze#4961
xmkg wants to merge 4 commits into
mainfrom
bugfix/cli-tests-win-fix-event-loop-freeze

Conversation

@xmkg

@xmkg xmkg commented Jun 17, 2026

Copy link
Copy Markdown
Member

Win: Avoid blocking the event loop on close

EvtClose can wait for in-flight callbacks, stalling pytest daemon teardown. Close the subscription on a detached daemon thread so pytest daemon teardown is not stalled if it blocks.

xmkg added 2 commits June 17, 2026 10:49
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
EvtClose can wait for in-flight callbacks, stalling pytest daemon
teardown.Close the subscription on a detached daemon thread so pytest
daemon teardown is not stalled if it blocks.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.84%. Comparing base (88ea3ce) to head (160516e).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4961   +/-   ##
=======================================
  Coverage   87.84%   87.84%           
=======================================
  Files         271      271           
  Lines       14669    14669           
=======================================
  Hits        12884    12884           
  Misses       1785     1785           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xmkg xmkg requested review from a team and ricab and removed request for a team June 17, 2026 08:52
Win10 is timing out in some instances.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a Windows-specific pytest teardown hang by avoiding blocking the asyncio event loop thread during Windows Event Log subscription cleanup.

Changes:

  • Add a run_detached_thread() helper to run best-effort blocking cleanup on a daemon thread.
  • Update the Windows service controller’s Event Log follower to close Event Log handles asynchronously during generator teardown.
  • Increase the default CLI test timeout for the start command.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/cli/utilities/threadutils.py Adds run_detached_thread() helper for detached daemon-thread execution.
tests/cli/utilities/__init__.py Re-exports run_detached_thread from utilities.
tests/cli/controller/winsvc_multipassd_controller.py Uses detached thread cleanup for Event Log subscription close; adds shutdown signaling.
tests/cli/conftest.py Increases default start command timeout from 90s to 180s.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/cli/controller/winsvc_multipassd_controller.py Outdated
Comment thread tests/cli/controller/winsvc_multipassd_controller.py
Comment thread tests/cli/controller/winsvc_multipassd_controller.py

@ricab ricab left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am OK with this modulo copilot flaggings.

Copilot finished work on behalf of xmkg June 19, 2026 08:57
Copilot finished work on behalf of xmkg June 19, 2026 09:01
@xmkg xmkg force-pushed the bugfix/cli-tests-win-fix-event-loop-freeze branch from 20d56a0 to ab3228c Compare June 19, 2026 09:03
@xmkg xmkg requested a review from Copilot June 19, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/cli/utilities/__init__.py
@xmkg xmkg requested a review from ricab June 19, 2026 09:08

@ricab ricab left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small suggestion/question inline.

Comment thread tests/cli/controller/winsvc_multipassd_controller.py
@ricab

ricab commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Also, the last commit is unverified. Would that be easy to fix @xmkg ?

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
@xmkg xmkg force-pushed the bugfix/cli-tests-win-fix-event-loop-freeze branch from ab3228c to 160516e Compare June 19, 2026 17:43
@xmkg

xmkg commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Also, the last commit is unverified. Would that be easy to fix @xmkg ?

Fixed

@ricab ricab left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another detail I didn't notice before. Otherwise alright.

# scheduling in case the loop is already closing.
if closing.is_set():
return
with suppress(RuntimeError):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't suppose there is a more specific type this could catch, to avoid sinking other problems?

Comment thread tests/cli/controller/winsvc_multipassd_controller.py
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.

4 participants