from oscpy.server import OSCThreadServer
def callback(*values):
print("foreground got values: {}".format(values[0]))
osc = OSCThreadServer(encoding = 'utf8')
sock = osc.listen(address = '0.0.0.0', port = 3000, default = True)
osc.bind(b'/foreground_listening', callback)
# the following line crashes the listening thread:
osc.send_message(b'/background_listening', ["calling background!"], ip_address = '127.0.0.1', port = 3001)
input("press 'enter' ...")
osc.stop()
press 'enter' ...
Exception in thread Thread-1:
Traceback (most recent call last):
File "c:\python37\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "c:\python37\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\arbeit\programme\TollIna\venv\lib\site-packages\oscpy\server.py", line 335, in _listen
data, sender = sender_socket.recvfrom(65535)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
osc.send_message(..." everything works as expected.
(venv2) C:\arbeit\oscpy-fork-heideachim\tests>pytest test_server.py
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-4.6.5, py-1.8.0, pluggy-0.12.0
rootdir: C:\arbeit\oscpy-fork-heideachim
collected 34 items
test_server.py .................................. [100%]
========================== 34 passed in 0.67 seconds ==========================
(venv) C:\arbeit\oscpy-fork-heideachim\tests>pytest test_server.py
========================================================================================= test session starts ===========================================================
platform win32 -- Python 3.7.2, pytest-5.1.1, py-1.8.0, pluggy-0.12.0
rootdir: C:\arbeit\oscpy-fork-heideachim
collected 34 items
test_server.py .........Exception in thread Thread-10:
Traceback (most recent call last):
File "c:\python37\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "c:\python37\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "c:\arbeit\programme\tollina\venv\lib\site-packages\oscpy\server.py", line 336, in _listen
data, sender = sender_socket.recvfrom(65535)
ConnectionResetError: [WinError 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
.
....<socket.socket fd=596, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 63312)>
.<socket.socket fd=616, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 63313)>
................... [100%]
==================================================================================== 34 passed in 69.08s (0:01:09) ======================================================
(venv2) C:\arbeit\oscpy\oscpy-fork-achim\tests>pytest test_server.py
============================= test session starts =============================
platform win32 -- Python 2.7.16, pytest-4.6.5, py-1.8.0, pluggy-0.12.0
rootdir: C:\arbeit\oscpy\oscpy-fork-achim
collected 34 items
test_server.py ..........Exception in thread Thread-10:
Traceback (most recent call last):
File "c:\python27\Lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "c:\python27\Lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "c:\arbeit\oscpy\venv2\lib\site-packages\oscpy\server.py", line 335, in _listen
data, sender = sender_socket.recvfrom(65535)
error: [Errno 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
........................ [100%]
========================== 34 passed in 1.13 seconds ==========================
(venv3) C:\arbeit\oscpy\oscpy-fork-achim\tests>pytest test_server.py
================================================= test session starts =================================================
platform win32 -- Python 3.7.2, pytest-5.1.1, py-1.8.0, pluggy-0.12.0
rootdir: C:\arbeit\oscpy\oscpy-fork-achim
collected 34 items
test_server.py .......Exception in thread Thread-8:
Traceback (most recent call last):
File "c:\python37\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "c:\python37\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "c:\arbeit\oscpy\venv3\lib\site-packages\oscpy\server.py", line 335, in _listen
data, sender = sender_socket.recvfrom(65535)
OSError: [WinError 10038] an operation was attempted on something that is not a socket
..Exception in thread Thread-10:
Traceback (most recent call last):
File "c:\python37\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "c:\python37\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "c:\arbeit\oscpy\venv3\lib\site-packages\oscpy\server.py", line 335, in _listen
data, sender = sender_socket.recvfrom(65535)
ConnectionResetError: [WinError 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
......................... [100%]
================================================== warnings summary ===================================================
test_server.py:864
C:\arbeit\oscpy\oscpy-fork-achim\tests\test_server.py:864: DeprecationWarning: invalid escape sequence \(
match='get_sender\(\) not called from a callback'):
-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================== 34 passed, 1 warnings in 14.97s ===========================================
ConnectionResetError
. But pytest continues normally and reports all tests as successfull! See my post in https://kivy.org/#?place=msg%2Fkivy-users%2FGDQr9I4DBy0%2F9HIMA1EfBAAJ, all 34 tests where passed successfully, despite the exception.