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

2
src/jmclient/blockchaininterface.py

@ -442,7 +442,7 @@ class BitcoinCoreInterface(BlockchainInterface):
log.error("Failure of RPC connection to Bitcoin Core. " log.error("Failure of RPC connection to Bitcoin Core. "
"Application cannot continue, shutting down.") "Application cannot continue, shutting down.")
stop_reactor() stop_reactor()
return None twisted_sys_exit(EXIT_FAILURE)
# note that JsonRpcError is not caught here; for some calls, we # note that JsonRpcError is not caught here; for some calls, we
# have specific behaviour requirements depending on these errors, # have specific behaviour requirements depending on these errors,
# so this is handled elsewhere in BitcoinCoreInterface. # 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 twisted.internet import reactor
from jmbase import jmprint from jmbase import jmprint, stop_reactor
def wrap_main(func): def wrap_main(func):
@ -18,13 +18,9 @@ def wrap_main(func):
except SystemExit as e: except SystemExit as e:
return e.args[0] if e.args else None return e.args[0] if e.args else None
finally: finally:
try: for task in asyncio.all_tasks():
for task in asyncio.all_tasks(): task.cancel()
task.cancel() stop_reactor()
if reactor.running:
reactor.stop()
except Exception as e:
jmprint(f'Errors during reactor cleaenup/stop: {e}', 'debug')
return func_wrapper return func_wrapper

Loading…
Cancel
Save