Commit Graph

13 Commits

Author SHA1 Message Date
SomberNight d4338fb503 tests: clean-up use of asyncio 2023-02-20 16:53:44 +00:00
SomberNight 84faf7f99a tests: fix TestLNTransport probabilistic failure
lucky CI run: https://github.com/spesmilo/electrum/runs/9273471816
2022-11-03 15:45:15 +00:00
SomberNight 872ce82418 tests: clean up event-loop creation 2022-05-04 01:53:21 +02:00
SomberNight 2c57c78ebe asyncio: stop using get_event_loop(). introduce ~singleton loop.
asyncio.get_event_loop() became deprecated in python3.10. (see https://github.com/python/cpython/issues/83710)
```
.../electrum/electrum/daemon.py:470: DeprecationWarning: There is no current event loop
  self.asyncio_loop = asyncio.get_event_loop()
.../electrum/electrum/network.py:276: DeprecationWarning: There is no current event loop
  self.asyncio_loop = asyncio.get_event_loop()
```
Also, according to that thread, "set_event_loop() [... is] not deprecated by oversight".
So, we stop using get_event_loop() and set_event_loop() in our own code.
Note that libraries we use (such as the stdlib for python <3.10), might call get_event_loop,
which then relies on us having called set_event_loop e.g. for the GUI thread. To work around
this, a custom event loop policy providing a get_event_loop implementation is used.

Previously, we have been using a single asyncio event loop, created with
util.create_and_start_event_loop, and code in many places got a reference to this loop
using asyncio.get_event_loop().
Now, we still use a single asyncio event loop, but it is now stored as a global in
util._asyncio_event_loop (access with util.get_asyncio_loop()).

I believe these changes also fix https://github.com/spesmilo/electrum/issues/5376
2022-04-29 18:49:07 +02:00
SomberNight c9c094cfab requirements: bump min aiorpcx to 0.22.0
aiorpcx 0.20 changed the behaviour/API of TaskGroups.
When used as a context manager, TaskGroups no longer propagate
exceptions raised by their tasks. Instead, the calling code has
to explicitly check the results of tasks and decide whether to re-raise
any exceptions.
This is a significant change, and so this commit introduces "OldTaskGroup",
which should behave as the TaskGroup class of old aiorpcx. All existing
usages of TaskGroup are replaced with OldTaskGroup.

closes https://github.com/spesmilo/electrum/issues/7446
2022-02-15 18:22:44 +01:00
SomberNight 4f13c451c7 tests: rework lntransport test a bit
send multiple messages, and not only short ones
2021-03-21 22:11:16 +01:00
SomberNight 223b62554e lntransport: use network proxy if available
fixes #4824
2020-04-15 21:44:09 +02:00
SomberNight 74a3faf803 crypto: add 'cryptography' as alt dependency for 'pycryptodomex' 2020-03-04 18:54:20 +01:00
SomberNight dae842e2ad tests: made TestLNTransport.test_loop more robust 2020-03-04 17:57:40 +01:00
SomberNight 308517d473 python 3.8: adapt to breaking changes re asyncio.CancelledError
(and TimeoutError)

closes #5798
2019-12-11 23:07:47 +01:00
SomberNight 04edad9984 config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
ThomasV 8e753f998a fix tests 2019-08-20 09:03:11 +02:00
Janus 962f70c7da ln: add lightning_listen config option 2019-08-20 09:03:10 +02:00