Browse Source

fix BitcoinCoreInterface._rpc, twisted_sys_exit, finalize_main_task

add_frost
zebra-lucky 2 weeks ago
parent
commit
347a4a4077
  1. 6
      src/jmbase/support.py
  2. 2
      src/jmclient/blockchaininterface.py
  3. 12
      src/jmclient/scripts_support.py

6
src/jmbase/support.py

@ -11,6 +11,7 @@ from sqlite3 import Cursor, Row
from typing import Callable, List, Optional
import urllib.parse as urlparse
# JoinMarket version
JM_CORE_VERSION = '0.9.12dev'
@ -25,9 +26,8 @@ EXIT_ARGERROR = 2
def twisted_sys_exit(status):
from twisted.internet import reactor
if reactor.running:
reactor.stop()
from .twisted_utils import stop_reactor
stop_reactor()
sys.exit(status)

2
src/jmclient/blockchaininterface.py

@ -442,7 +442,7 @@ class BitcoinCoreInterface(BlockchainInterface):
log.error("Failure of RPC connection to Bitcoin Core. "
"Application cannot continue, shutting down.")
stop_reactor()
return None
twisted_sys_exit(EXIT_FAILURE)
# note that JsonRpcError is not caught here; for some calls, we
# have specific behaviour requirements depending on these errors,
# so this is handled elsewhere in BitcoinCoreInterface.

12
src/jmclient/scripts_support.py

@ -6,7 +6,7 @@ from functools import wraps
from twisted.internet import reactor
from jmbase import jmprint
from jmbase import jmprint, stop_reactor
def wrap_main(func):
@ -18,13 +18,9 @@ def wrap_main(func):
except SystemExit as e:
return e.args[0] if e.args else None
finally:
try:
for task in asyncio.all_tasks():
task.cancel()
if reactor.running:
reactor.stop()
except Exception as e:
jmprint(f'Errors during reactor cleaenup/stop: {e}', 'debug')
for task in asyncio.all_tasks():
task.cancel()
stop_reactor()
return func_wrapper

Loading…
Cancel
Save