trevert ed086934e5f57745580628a5706a6a40856c695a (this does not work well with travis) - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 10e186c1d312f1a13f6d86246b0397dbe779afdd DIR parent 6f333bd86d1aa26cc23f09947f74358367262cf8 HTML Author: ThomasV <thomasv@electrum.org> Date: Fri, 30 Aug 2019 15:57:01 +0200 revert ed086934e5f57745580628a5706a6a40856c695a (this does not work well with travis) Diffstat: M electrum/tests/regtest/regtest.sh | 6 ++++++ M run_electrum | 37 +++++-------------------------- 2 files changed, 11 insertions(+), 32 deletions(-) --- DIR diff --git a/electrum/tests/regtest/regtest.sh b/electrum/tests/regtest/regtest.sh t@@ -159,6 +159,7 @@ fi if [[ $1 == "redeem_htlcs" ]]; then $bob stop ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=10 $bob daemon start + sleep 1 $bob load_wallet sleep 1 # alice opens channel t@@ -204,6 +205,7 @@ fi if [[ $1 == "breach_with_unspent_htlc" ]]; then $bob stop ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon start + sleep 1 $bob load_wallet wait_for_balance alice 1 echo "alice opens channel" t@@ -235,6 +237,7 @@ fi if [[ $1 == "breach_with_spent_htlc" ]]; then $bob stop ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon start + sleep 1 $bob load_wallet wait_for_balance alice 1 echo "alice opens channel" t@@ -275,6 +278,7 @@ if [[ $1 == "breach_with_spent_htlc" ]]; then $alice stop cp /tmp/alice/regtest/wallets/toxic_wallet /tmp/alice/regtest/wallets/default_wallet $alice daemon start + sleep 1 $alice load_wallet # wait until alice has spent both ctx outputs echo "alice spends to_local and htlc outputs" t@@ -283,6 +287,7 @@ if [[ $1 == "breach_with_spent_htlc" ]]; then new_blocks 1 echo "bob comes back" $bob daemon start + sleep 1 $bob load_wallet wait_for_balance bob 0.049 $bob getbalance t@@ -297,6 +302,7 @@ if [[ $1 == "watchtower" ]]; then $carol setconfig watchtower_port 12345 $carol daemon start $alice daemon start + sleep 1 $alice load_wallet wait_for_balance alice 1 echo "alice opens channel" DIR diff --git a/run_electrum b/run_electrum t@@ -24,7 +24,6 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import os -import time import sys import warnings import asyncio t@@ -274,16 +273,6 @@ def sys_exit(i): loop_thread.join(timeout=1) sys.exit(i) -def can_ping_daemon(config): - try: - daemon.request(config, 'ping') - return True - except daemon.DaemonNotRunning: - return False - except BaseException as e: - print_stderr(e) - return False - if __name__ == '__main__': # The hook will only be used in the Qt GUI right now util.setup_thread_excepthook() t@@ -359,8 +348,6 @@ if __name__ == '__main__': # todo: defer this to gui config = SimpleConfig(config_options) - # this sets rpc_password as side effect - daemon.get_rpc_credentials(config) cmdname = config.get('cmd') subcommand = config.get('subcommand') t@@ -374,28 +361,12 @@ if __name__ == '__main__': elif config.get('lightning') and not config.get('reckless'): raise Exception('lightning branch not available on mainnet') - loop, stop_loop, loop_thread = create_and_start_event_loop() - if cmdname == 'daemon' and subcommand == 'start': - if can_ping_daemon(config): - print_stderr('daemon already running') - sys_exit(1) - loop.call_soon_threadsafe(stop_loop.set_result, 1) - loop_thread.join(timeout=1) - # we must fork before creating the asyncio event loop, - # see https://bugs.python.org/issue21998 + # fork before creating the asyncio event loop pid = os.fork() - loop, stop_loop, loop_thread = create_and_start_event_loop() if pid: - for i in range(10): - if can_ping_daemon(config): - break - time.sleep(0.5) - else: - print_stderr("Could not contact daemon, giving up") - sys_exit(1) - print_stderr("Daemon started (PID %d)" % pid) - sys_exit(0) + print_stderr("starting daemon (PID %d)" % pid) + sys.exit(0) else: # redirect standard file descriptors sys.stdout.flush() t@@ -407,6 +378,8 @@ if __name__ == '__main__': os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno()) + loop, stop_loop, loop_thread = create_and_start_event_loop() + if cmdname == 'gui': configure_logging(config) fd = daemon.get_file_descriptor(config)