tests: maybe fix tearDown() issue in test_storage_upgrade.py
from travis logs:
--- Logging error ---
Traceback (most recent call last):
File "/opt/python/3.7.6/lib/python3.7/logging/__init__.py", line 1028, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/opt/python/3.7.6/lib/python3.7/threading.py", line 890, in _bootstrap
self._bootstrap_inner()
File "/opt/python/3.7.6/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/home/travis/build/spesmilo/electrum/electrum/plugin.py", line 213, in run
self.run_jobs()
File "/home/travis/build/spesmilo/electrum/electrum/util.py", line 359, in on_stop
self.logger.info("stopped")
Message: 'stopped'
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
from typing import Optional
|
||||
import asyncio
|
||||
|
||||
import electrum
|
||||
from electrum.wallet_db import WalletDB
|
||||
from electrum.wallet import Wallet
|
||||
from electrum import constants
|
||||
@@ -312,6 +313,8 @@ class TestStorageUpgrade(WalletTestCase):
|
||||
|
||||
##########
|
||||
|
||||
plugins: 'electrum.plugin.Plugins'
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
@@ -323,12 +326,14 @@ class TestStorageUpgrade(WalletTestCase):
|
||||
|
||||
gui_name = 'cmdline'
|
||||
# TODO it's probably wasteful to load all plugins... only need Trezor
|
||||
Plugins(config, gui_name)
|
||||
cls.plugins = Plugins(config, gui_name)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super().tearDownClass()
|
||||
shutil.rmtree(cls.__electrum_path)
|
||||
cls.plugins.stop()
|
||||
cls.plugins.stopped_event.wait()
|
||||
|
||||
def _upgrade_storage(self, wallet_json, accounts=1) -> Optional[WalletDB]:
|
||||
if accounts == 1:
|
||||
@@ -358,8 +363,8 @@ class TestStorageUpgrade(WalletTestCase):
|
||||
def _sanity_check_upgraded_db(self, db):
|
||||
self.assertFalse(db.requires_split())
|
||||
self.assertFalse(db.requires_upgrade())
|
||||
w = Wallet(db, None, config=self.config)
|
||||
w.stop()
|
||||
wallet = Wallet(db, None, config=self.config)
|
||||
asyncio.run_coroutine_threadsafe(wallet.stop(), self.asyncio_loop).result()
|
||||
|
||||
@staticmethod
|
||||
def _load_db_from_json_string(*, wallet_json, manual_upgrades):
|
||||
|
||||
@@ -317,6 +317,7 @@ class DaemonThread(threading.Thread, Logger):
|
||||
self.running_lock = threading.Lock()
|
||||
self.job_lock = threading.Lock()
|
||||
self.jobs = []
|
||||
self.stopped_event = threading.Event() # set when fully stopped
|
||||
|
||||
def add_jobs(self, jobs):
|
||||
with self.job_lock:
|
||||
@@ -357,6 +358,7 @@ class DaemonThread(threading.Thread, Logger):
|
||||
jnius.detach()
|
||||
self.logger.info("jnius detach")
|
||||
self.logger.info("stopped")
|
||||
self.stopped_event.set()
|
||||
|
||||
|
||||
def print_stderr(*args):
|
||||
|
||||
Reference in New Issue
Block a user