Skip to content

Commit

Permalink
[electrum] don't raise RuntimeError for system thread limitations
Browse files Browse the repository at this point in the history
Summary:
This addresses Bitcoin-ABC/bitcoin-abc#533

`threading.Thread.start()` can raise a RuntimeError if a system limit on how many threads can run is reached. Don't alarm the user with an Error dialog in such a case, just ignore it silently and hope it works next time.
In verbose mode a message is logged about the aborted request.

Test Plan:
```
$ ./electrum-abc --test-release-notification -v
|  7.785| |07| [_Req@21536] Requesting from /home/pierre/dev/bitcoin-abc/electrum/electrumabc_gui/qt/../../contrib/update_checker/releases.json ...
[_Req@21536] {'5.2.8': {'ecash:qz5j83ez703wvlwpqh94j6t45f8dn2afjgtgurgua0': 'H81ib52w4RttgGJu7lJACX00fkMz/FqZhCegcU5kp8ouaZ/2pSJurIgAxRsrd8EojjYKs4TTTLrIgn/guyYgdew='}}
|  7.797| |00| [UpdateChecker] Downloading progress 10% from https://raw.githubusercontent.com/Bitcoin-ABC/bitcoin-abc/master/electrum/contrib/update_checker/releases.json
|  7.811| |00| [UpdateChecker] Downloading progress 100% from https://raw.githubusercontent.com/Bitcoin-ABC/bitcoin-abc/master/electrum/contrib/update_checker/releases.json
|  7.819| |00| [UpdateChecker] Got new version 5.2.8
|  7.820| |00| [UpdateChecker] Active _Req@21536 finished

```

With a `raise RuntimeError()`  added to the `try:` scope before `start()`
```
$ ./electrum-abc --test-release-notification -v
|  9.933| |00| [UpdateChecker] Aborted _Req@50944 finished
```

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14674
  • Loading branch information
PiRK authored and abc-bot committed Oct 26, 2023
1 parent 5c62d5e commit cd7cd45
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion electrumabc_gui/qt/update_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,13 @@ def __init__(self, checker, is_test_run: bool):
self.aborted = False
self.json = None
self.is_test_run = is_test_run
self.start()
try:
self.start()
except RuntimeError:
# If the user hits a system limitation on the number of threads,
# ignore the error.
self.aborted = True
self.checker._req_finished.emit(self)

def abort(self):
self.aborted = True
Expand Down

0 comments on commit cd7cd45

Please sign in to comment.