-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #673. Shutdown cleanly on failure to access blockheight
Prior to this commit, in case an RPC failure occurred when accesing the block height, the program would continue but the wallet would be in an un-writeable state (for command line programs, specifically yield generators; for Qt the shutdown would occur). This commit slightly cleans up the process of shutting down, ensuring that duplicate shutdown calls do not result in stack traces. It also ensures that also for command line programs, the application will immediately shutdown if the regular heartbeat call to query the block height fails, as this risks inconsistencies in the wallet (though the previous situation luckily did not result in this as the call to BaseWallet.close() resulted in the wallet being read only). A future PR should develop a more sophisticated approach to RPC call failures that may allow the program to wait. stopservice
- Loading branch information
Showing
6 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
from twisted.internet.error import ReactorNotRunning, AlreadyCancelled | ||
from twisted.internet import reactor | ||
|
||
def stop_reactor(): | ||
""" Both in startup and shutdown, | ||
the value of the bool `reactor.running` | ||
does not reliably tell us whether the | ||
reactor is running (!). There are startup | ||
and shutdown phases not reported externally | ||
by IReactorCore. | ||
Hence the Exception catch is needed here. | ||
""" | ||
try: | ||
if reactor.running: | ||
reactor.stop() | ||
except ReactorNotRunning: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters