kivy / oscpy

An efficient OSC implementation compatible with python2.7 and 3.5+
MIT License
109 stars 27 forks source link

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

Closed Thong-Tran closed 5 years ago

Thong-Tran commented 5 years ago

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):


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)
tshirtman commented 5 years ago

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

tshirtman commented 5 years ago

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

Thong-Tran commented 5 years ago

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

Thong-Tran commented 5 years ago

Hi @tshirtman, both android and ios work well 👌

tshirtman commented 5 years ago

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