Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Feb 12, 2024
1 parent 8e4f9b8 commit ead7d37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/psygnal/_evented_model_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def __setattr__(self, name: str, value: Any) -> None:
if (
len(signal_instance) < 2 # the signal itself has no listeners
and not deps_with_callbacks # no dependent properties with listeners
and not len(self._events) # no listeners on the SignalGroup
and not len(self._events._psygnal_relay) # no listeners on the SignalGroup
):
return self._super_setattr_(name, value)

Expand Down
2 changes: 1 addition & 1 deletion src/psygnal/_evented_model_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def __setattr__(self, name: str, value: Any) -> None:
if (
len(signal_instance) < 2 # the signal itself has no listeners
and not deps_with_callbacks # no dependent properties with listeners
and not len(self._events) # no listeners on the SignalGroup
and not len(self._events._psygnal_relay) # no listeners on the SignalGroup
):
return self._super_setattr_(name, value)

Expand Down
14 changes: 13 additions & 1 deletion src/psygnal/_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,19 @@ def __getstate__(self) -> dict:
)
dd = {slot: getattr(self, slot) for slot in attrs}
dd["_instance"] = self._instance()
dd["_slots"] = [x for x in self._slots if isinstance(x, StrongFunction)]
dd["_slots"] = [
x
for x in self._slots
if (
isinstance(x, StrongFunction)
# HACK
# this is a hack to retain the ability of a deep-copied signal group
# to connect to all signals in the group.
# reconsider this mechanism. It could also be achieved more directly
# as a special __deepcopy__ method on SignalGroup
or getattr(x, "_obj_qualname", None) == "SignalRelay._slot_relay"
)
]
if len(self._slots) > len(dd["_slots"]):
warnings.warn(
"Pickling a SignalInstance does not copy connected weakly referenced "
Expand Down
6 changes: 5 additions & 1 deletion src/psygnal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Callable, Generator, Iterator
from warnings import warn

from ._group2 import EmissionInfo, SignalGroup
from ._group2 import EmissionInfo, SignalGroup, SignalRelay
from ._signal import SignalInstance

__all__ = ["monitor_events", "iter_signal_instances"]
Expand Down Expand Up @@ -58,6 +58,10 @@ def monitor_events(
)
disconnectors = set()
for siginst in iter_signal_instances(obj, include_private_attrs):
if isinstance(siginst, SignalRelay):
# TODO: ... but why?
continue

if _old_api:

def _report(*args: Any, signal: SignalInstance = siginst) -> None:
Expand Down

0 comments on commit ead7d37

Please sign in to comment.