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

Using object proxy as sender do not work #37

Closed
reidfaiv opened this issue Nov 27, 2017 · 1 comment
Closed

Using object proxy as sender do not work #37

reidfaiv opened this issue Nov 27, 2017 · 1 comment

Comments

@reidfaiv
Copy link

When application uses object proxy as sender in connect then signal is never delivered. This is due use of object id, which is different for real object and proxy.

For example when using https://pypi.python.org/pypi/lazy-object-proxy the signal is never received.

import blinker
from lazy_object_proxy import Proxy

class X(object):
    def receive(self, *args, **kwargs):
      print 'got signal'
    def send(self):
      print 'sending signal'
      test_signal.send(self)

x = X()

def get_x():
    return x

x_proxy = Proxy(get_x)  # Lazy object proxy is useful sometimes

test_signal = blinker.Signal()
test_signal.connect(x_proxy.receive, sender=x_proxy)

x_proxy.send()  # never received because id(x) != id(x_proxy)

Even though x and x_proxy have different id values, the normal equal comparison works, as well as hash() returns same value:

>>> id(x) == id(x_proxy)
False
>>> x == x_proxy
True
>>> hash(x) == hash(x_proxy)
True

It is similar issue as reported in #30 and similar solution (using hash) would help.

@jek
Copy link
Contributor

jek commented Nov 30, 2017

hash() values are not unique across types (or guaranteed unique amongst instances of types), which is why identity is used now.

@jek jek closed this as completed Nov 30, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants