brainvisa/anatomist-gpl

setting a notifier in the threaded implementation of pyanatomist causes errors

Closed this issue · 0 comments

Describe the bug
The test program:

import anatomist.threaded.api as anatomist

def testHandler(x,y):
    print("CLICK ", x, " // ",y)

a = anatomist.Anatomist()
a.onCursorNotifier.add(testHandler)

causes the following error when setting the notifier (last line):

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-847b0e3b9316> in <module>()
      5 
      6 a = anatomist.Anatomist()
----> 7 a.onCursorNotifier.add(testHandler)

/casa/host/build/python/soma/notification.py in add(self, listener)
   1473         if nbListenersBefore == 0:  # before add : 0 listener, after : 1 listener -> add first listener
   1474             if len(self._listeners) == 1:
-> 1475                 self.onAddFirstListener.notify()
   1476 
   1477     def remove(self, listener):

/casa/host/build/python/soma/notification.py in notify(self, *args)
    146                         listener.notify(*args)
    147                     else:
--> 148                         listener(*args)
    149                 except ReferenceError:
    150                     # listener is deleted in a weak ref/proxy

/casa/host/build/python/soma/utils/weak_proxy.py in __call__(self, *args, **kwargs)
    115 
    116     def __call__(self, *args, **kwargs):
--> 117         return getattr(self.proxy, self.method)(*args, **kwargs)

/casa/host/build/python/anatomist/direct/api.py in __getattr__(self, name)
    717             return self.mniTemplateRef
    718         else:
--> 719             raise AttributeError(name)
    720 
    721     def __getattribute__(self, name):

AttributeError: <lambda>