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

Don't unblock/resume within nested contexts #150

Merged
merged 3 commits into from
Dec 4, 2022

Conversation

hanjinliu
Copy link
Contributor

Signals are unblocked on exit of blocked context, which will cause problematic signal emission within nested contexts.

from psygnal import Signal
class A:
    sig = Signal(int)
a = A()

a.sig.connect(print)

with a.sig.blocked():
    with a.sig.blocked():
        a.sig.emit(0)
    a.sig.emit(1)  # <----------- will be emitted

This PR fixes the problem above by checking if the signal is blocked first, and restore the original state on exit.

@tlambert03
Copy link
Member

thanks @hanjinliu, good one.

looks like tests are failing, but it's not your fault. You've hit on a funny/unexpected bug in the compiled version that somehow didn't surface in #149

I can reproduce locally, and will try to fix and push soon

@tlambert03
Copy link
Member

hey @hanjinliu ... I think I have a fix for the tests here, but can't merge to your PR. can you merge hanjinliu#1

fix: fix pauser context manager in compiled code
@codecov
Copy link

codecov bot commented Dec 4, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (a6d3a76) compared to base (3f52065).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #150   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1411      1418    +7     
=========================================
+ Hits          1411      1418    +7     
Impacted Files Coverage Δ
src/psygnal/_signal.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@tlambert03 tlambert03 left a comment

Choose a reason for hiding this comment

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

thanks @hanjinliu!

@tlambert03 tlambert03 merged commit d384e87 into pyapp-kit:main Dec 4, 2022
@tlambert03 tlambert03 added the bug Something isn't working label Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants