Browse Source

asyncio: sql_db: maybe fix "no current event loop in thread"

see https://github.com/spesmilo/electrum/issues/5376
crash report for electrum 4.2.1:
```
Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 347, in mainloop
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 391, in idle
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 342, in dispatch_input
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/base.py", line 308, in post_dispatch_input
  File "kivy/_event.pyx", line 724, in kivy._event.EventDispatcher.dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/uix/behaviors/button.py", line 179, in on_touch_up
  File "kivy/_event.pyx", line 720, in kivy._event.EventDispatcher.dispatch
  File "kivy/_event.pyx", line 1263, in kivy._event.EventObservers.dispatch
  File "kivy/_event.pyx", line 1147, in kivy._event.EventObservers._dispatch
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Electrum/kivy/lang/builder.py", line 57, in custom_callback
  File "<string>", line 39, in <module>
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/uix/dialogs/settings.py", line 173, in cb
  File "kivy/properties.pyx", line 498, in kivy.properties.Property.__set__
  File "kivy/properties.pyx", line 545, in kivy.properties.Property.set
  File "kivy/properties.pyx", line 600, in kivy.properties.Property.dispatch
  File "kivy/_event.pyx", line 1263, in kivy._event.EventObservers.dispatch
  File "kivy/_event.pyx", line 1169, in kivy._event.EventObservers._dispatch
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/kivy/main_window.py", line 206, in on_use_gossip
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/network.py", line 368, in start_gossip
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/channel_db.py", line 308, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/sql_db.py", line 30, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/asyncio/locks.py", line 260, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/asyncio/events.py", line 639, in get_event_loop
RuntimeError: There is no current event loop in thread 'GUI'.
```
patch-4
SomberNight 3 years ago
parent
commit
1dd6a2019a
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 1
      electrum/sql_db.py

1
electrum/sql_db.py

@ -26,6 +26,7 @@ class SqlDB(Logger):
def __init__(self, asyncio_loop: asyncio.BaseEventLoop, path, commit_interval=None):
Logger.__init__(self)
self.asyncio_loop = asyncio_loop
asyncio.set_event_loop(asyncio_loop)
self.stopping = False
self.stopped_event = asyncio.Event()
self.path = path

Loading…
Cancel
Save