Commit Graph

16 Commits

Author SHA1 Message Date
SomberNight
d4338fb503 tests: clean-up use of asyncio 2023-02-20 16:53:44 +00:00
SomberNight
373db76ac9 util: kill bh2u
no longer useful, and the name is so confusing...
2023-02-17 11:43:11 +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
1600241b02 fix tests: follow-up prev few commits 2020-04-15 17:39:39 +02:00
SomberNight
ed234d3444 rename all TaskGroup() fields to "taskgroup"
for consistency
2020-02-27 19:13:56 +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
SomberNight
141ff99580 blockchain.py: generalise fork ids to get rid of conflicts 2018-11-22 16:57:22 +01:00
SomberNight
9d7cf12244 follow-up prev: fix tests 2018-09-25 17:00:43 +02:00
SomberNight
7221fb3231 interface: further simplifications for fork resolution 2018-09-17 22:30:25 +02:00
SomberNight
b3a2bce213 interface: simplify fork resolution logic 2018-09-17 22:30:21 +02:00
SomberNight
da23e71db1 interface: block header search simplifications 2018-09-16 07:34:05 +02:00
SomberNight
cdca74aa39 move max_checkpoint from network to constants 2018-09-09 05:00:09 +02:00
Janus
d367199553 async block headers: remove BlockHeaderInterface and Conn classes, make self.height a local 2018-09-06 14:17:45 +02:00
Janus
9c363db440 async block headers: avoid duplicate tip fields, handle electrumx server skipping blocks 2018-09-06 14:17:44 +02:00
Janus
e9ceeb85af async block headers 2018-09-06 14:17:41 +02:00