Skip to content

Add hard reference to the future in CallCallable - #373

Merged
tlambert03 merged 3 commits into
pyapp-kit:mainfrom
Czaki:fix_ensure_main_thread
Nov 19, 2026
Merged

tlambert03 merged 3 commits into
pyapp-kit:mainfrom
Czaki:fix_ensure_main_thread

Conversation

@Czaki

@Czaki Czaki commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

When running a test in napari it happens with the PySide6 backend to reach the deadlock. It looks like a bug in PySide6 code (wrong order of acquiring locks). But the deadlock was caused by a garbage collector that removed future instances (if I correctly understand the workflow).

The problematic schedule is:

  1. _run_in_thread finish its execution
  2. Garbage collector removes future object
  3. PySide6 spot that weakref to future.set_result is not longerwalid
  4. PySide6 might stuck in its own deadlock.

This PR allows omitting it by keeping a hard reference to the future object until work is done.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.04%. Comparing base (51cb32e) to head (ad5266b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #373      +/-   ##
==========================================
- Coverage   85.05%   85.04%   -0.02%     
==========================================
  Files          49       49              
  Lines        3975     3971       -4     
==========================================
- Hits         3381     3377       -4     
  Misses        594      594              

☔ 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.

@tlambert03 tlambert03 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks! looks good to me. i tested on a range of qt backends and versions and it worked across all.

@tlambert03
tlambert03 merged commit 4e3c80a into pyapp-kit:main Nov 19, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants