service.stop() fails
RobertFlatt opened this issue · 1 comments
RobertFlatt commented
service.stop() fails on desktop and on Android for different reasons.
Desktop: threading.Thread() has no stop() method
Android, using the same buildozer.spec : pyjnius is not happy
11-05 16:51:41.447 30426 30460 I python : Traceback (most recent call last):
11-05 16:51:41.447 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/app/main.py", line 116, in <module>
11-05 16:51:41.447 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/app.py", line 855, in run
11-05 16:51:41.448 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/base.py", line 504, in runTouchApp
11-05 16:51:41.448 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/core/window/window_sdl2.py", line 747, in mainloop
11-05 16:51:41.448 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/core/window/window_sdl2.py", line 479, in _mainloop
11-05 16:51:41.448 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/base.py", line 342, in idle
11-05 16:51:41.449 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/base.py", line 327, in dispatch_input
11-05 16:51:41.449 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/base.py", line 233, in post_dispatch_input
11-05 16:51:41.449 30426 30460 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.449 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/core/window/__init__.py", line 1402, in on_motion
11-05 16:51:41.449 30426 30460 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.450 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/core/window/__init__.py", line 1418, in on_touch_down
11-05 16:51:41.450 30426 30460 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.450 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/uix/widget.py", line 549, in on_touch_down
11-05 16:51:41.450 30426 30460 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.450 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/uix/widget.py", line 549, in on_touch_down
11-05 16:51:41.451 30426 30460 I python : File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.451 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/uix/behaviors/button.py", line 151, in on_touch_down
11-05 16:51:41.451 30426 30460 I python : File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
11-05 16:51:41.451 30426 30460 I python : File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
11-05 16:51:41.452 30426 30460 I python : File "kivy/_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
11-05 16:51:41.452 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oscservice/kivy/lang/builder.py", line 64, in custom_callback
11-05 16:51:41.452 30426 30460 I python : File "<string>", line 12, in <module>
11-05 16:51:41.452 30426 30460 I python : File "/home/bobf/ex/service/.buildozer/android/app/main.py", line 100, in stop_service
11-05 16:51:41.452 30426 30460 I python : File "jnius/jnius_export_class.pxi", line 745, in jnius.jnius.JavaMethod.__call__
11-05 16:51:41.453 30426 30460 I python : jnius.jnius.JavaException: Invalid call, number of argument mismatch, got 0 need 1
11-05 16:51:41.453 30426 30460 I python : Python for android ended.
RobertFlatt commented
Worked around the issue by
- using oscpy==master
- Changing service_stop() to:
def stop_service(self):
if self.service:
self.client.send_message(b'/stop', [])
self.service = None
- Using the 'stop' message to break out of the send_date() loop:
stopped = False
def stop(*_):
global stopped
stopped = True
if __name__ == '__main__':
SERVER = OSCThreadServer()
SERVER.listen('localhost', port=3000, default=True)
SERVER.bind(b'/ping', ping)
SERVER.bind(b'/stop', stop)
SERVER.getaddress()
while True:
sleep(1)
if stopped:
break
send_date()
SERVER.terminate_server()
sleep(0.1)
SERVER.close()
Worked for me on Windows and Android, can start,stop,restart the service.