PyDispatcher question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorgen Bodde

    #1

    PyDispatcher question

    Hi all,

    Hopefully someone can help me. I am fairly new to Python, and I am
    looking into PyDispatcher. I am familiar with the C++ sigslot variant,
    and I wonder how similar PyDispatches is. I run in to the following
    'problem' (pseudo code, untested here)

    import pydispatch.disp atcher

    class A:
    def __init__(self):
    dispatcher.conn ect(self.someSi gnal, signal = 1)

    def someSignal(self ):
    print 'Hello world'

    obj = A()

    # send a trial signal

    dispatcher.send (signal = 1)
    >>Hello world
    # now for the catch, how to clean up?
    # if I do:
    obj = None # clean up

    dispatcher.send (signal = 1)
    >>Hello world
    The object still extists... Which is logical, the method is still
    bound to the signal, and the object itself is not yet deleted. Is
    there an elegant way to delete the object and let the signal unbind
    itself? Or do I need to do this in the destructor of the object? AFAIK
    there is no real destructor in Python?

    Do I need to do it differently? Or is there a better signal mechanism to use?

    Any help is appreciated!
    - Jorgen
Working...