kivy/oscpy

Android - iOS: get_sender() not called from a callback in file

Thong-Tran opened this issue · 5 comments

Describe the bug
__file__ != filename, because .py complied to .pyc
It should be:

if function == '_listen' and re.search(r'oscpy[\\/]server\.py', filename):
    break

To Reproduce

osc = OSCThreadServer()
sock = osc.listen(address='0.0.0.0', port=8000, default=True)

@osc.address(b'/ping')
def _identify_me(values):
    print(osc.get_sender())

Expected behavior
Print sender

Logs/output

05-13 09:44:16.672 13763 13905 I python  : [INFO   ] [osc         ]
05-13 09:44:16.672 13763 13905 I python  : __file__: ./_applibs/oscpy/server.pyc
05-13 09:44:16.672 13763 13905 I python  : filename: /home/user/.buildozer/android/app/_applibs/oscpy/server.py
05-13 09:44:16.673 13763 13905 I python  : [ERROR  ] [Catch Exception]
05-13 09:44:16.673 13763 13905 I python  : Traceback (most recent call last):
05-13 09:44:16.673 13763 13905 I python  :   File "/home/user/.buildozer/android/app/block/socketp2p.py", line 27, in f
05-13 09:44:16.673 13763 13905 I python  :   File "/home/user/.buildozer/android/app/block/socketp2p.py", line 101, in _identify_me
05-13 09:44:16.673 13763 13905 I python  :   File "/home/user/.buildozer/android/app/_applibs/oscpy/server.py", line 447, in get_sender
05-13 09:44:16.673 13763 13905 I python  : RuntimeError: get_sender() not called from a callback

Platform (please complete the following information):

  • OS: android, iOS
  • Python version: 3.7
  • release or git branch/commit: master f013d0e

Out Of Topic:
Can you add this to method OSCThreadServer.unbind:

if isinstance(address, UNICODE) and self.encoding:
      address = address.encode(
          self.encoding, errors=self.encoding_errors)

Indeed, didn't think about that, will look into these two things :)

Hello, Would you mind trying the fix on your side? Thanks in advance :)

OK. But I'm currently busy on some other projects. When i have time i will check it for you.

Hi @tshirtman, both android and ios work well 👌

Great, thanks for the report, merging then :).