schollii / pypubsub

A Python publish-subcribe library (moved here from SourceForge.net where I had it for many years)
198 stars 29 forks source link

Listener inadequate errors randomly appearing #57

Open rri-reds opened 10 months ago

rri-reds commented 10 months ago

Hello,

I am using pypubsub in the context of a program that uses cocotb to test some HDL code. I have a LARGE number of publisher and subscribers, and in the past few days I have started to receive this kind of errors:

INFO     cocotb:simulator.py:302 #   2500.00ns ERROR    root                               Listener "MyFun._myhandler" (from module "MyFun") inadequate: required args (msg) not allowed (could curry them), topic has no required args (params (msg) are req'd in listener, optional in topic )
INFO     cocotb:simulator.py:302 #                                                         Traceback (most recent call last):
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/test.py", line 138, in run_test
INFO     cocotb:simulator.py:302 #                                                             myfun = MyFun(config)
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/MyFun.py", line 67, in __init__
INFO     cocotb:simulator.py:302 #                                                             pub.subscribe(self._myhandler, mytopic)
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/.tox/py3/lib/python3.7/site-packages/pubsub/core/publisher.py", line 160, in subscribe
INFO     cocotb:simulator.py:302 #                                                             subscribedListener, success = topicObj.subscribe(listener, **curriedArgs)
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/.tox/py3/lib/python3.7/site-packages/pubsub/core/topicobj.py", line 356, in subscribe
INFO     cocotb:simulator.py:302 #                                                             argsInfo = self.__validator.validate(listener, curriedArgNames=curriedArgs)
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/.tox/py3/lib/python3.7/site-packages/pubsub/core/listener.py", line 274, in validate
INFO     cocotb:simulator.py:302 #                                                             self.__validateArgs(listener, paramsInfo, curriedArgNames)
INFO     cocotb:simulator.py:302 #                                                           File "MY_PATH/.tox/py3/lib/python3.7/site-packages/pubsub/core/listener.py", line 333, in __validateArgs
INFO     cocotb:simulator.py:302 #                                                             raise ListenerMismatchError(msg, listener, extraArgs)
INFO     cocotb:simulator.py:302 #                                                         pubsub.core.callables.ListenerMismatchError: Listener "MyFun._myhandler" (from module "MyFun") inadequate: required args (msg) not allowed (could curry them), topic has no required args (params (msg) are req'd in listener, optional in topic )

Please do note that I have not touched the file in question (I was working on a totally unrelated file, with totally unrelated topics...). Has anyone got a clue about why this is happening? I can easily circumvent the error by putting the argument as optional in the handler and then putting an assert to ensure that the argument value is not None, but this is quite annoying...

Thanks a lot!