fix unclean closing of blockchain.db
This commit is contained in:
parent
e6f84666c7
commit
ab067d1d3a
2 changed files with 15 additions and 1 deletions
|
@ -557,6 +557,14 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
await self.component_manager.stop()
|
await self.component_manager.stop()
|
||||||
else:
|
else:
|
||||||
self.component_startup_task.cancel()
|
self.component_startup_task.cancel()
|
||||||
|
# the wallet component might have not started
|
||||||
|
try:
|
||||||
|
wallet_component = self.component_manager.get_actual_component('wallet')
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
await wallet_component.stop()
|
||||||
|
await self.component_manager.stop()
|
||||||
log.info("stopped api components")
|
log.info("stopped api components")
|
||||||
await self.rpc_runner.cleanup()
|
await self.rpc_runner.cleanup()
|
||||||
await self.streaming_runner.cleanup()
|
await self.streaming_runner.cleanup()
|
||||||
|
|
|
@ -145,7 +145,7 @@ class AIOSQLite:
|
||||||
self.waiting_reads_metric.inc()
|
self.waiting_reads_metric.inc()
|
||||||
self.read_count_metric.inc()
|
self.read_count_metric.inc()
|
||||||
try:
|
try:
|
||||||
while self.writers: # more writes can come in while we are waiting for the first
|
while self.writers and not self._closing: # more writes can come in while we are waiting for the first
|
||||||
if not urgent_read and still_waiting and self.urgent_read_done.is_set():
|
if not urgent_read and still_waiting and self.urgent_read_done.is_set():
|
||||||
# throttle the writes if they pile up
|
# throttle the writes if they pile up
|
||||||
self.urgent_read_done.clear()
|
self.urgent_read_done.clear()
|
||||||
|
@ -153,6 +153,8 @@ class AIOSQLite:
|
||||||
# wait until the running writes have finished
|
# wait until the running writes have finished
|
||||||
await self.read_ready.wait()
|
await self.read_ready.wait()
|
||||||
still_waiting = True
|
still_waiting = True
|
||||||
|
if self._closing:
|
||||||
|
raise asyncio.CancelledError
|
||||||
return await asyncio.get_event_loop().run_in_executor(
|
return await asyncio.get_event_loop().run_in_executor(
|
||||||
self.reader_executor, read_only_fn, sql, parameters
|
self.reader_executor, read_only_fn, sql, parameters
|
||||||
)
|
)
|
||||||
|
@ -195,6 +197,8 @@ class AIOSQLite:
|
||||||
self.read_ready.clear()
|
self.read_ready.clear()
|
||||||
try:
|
try:
|
||||||
async with self.write_lock:
|
async with self.write_lock:
|
||||||
|
if self._closing:
|
||||||
|
raise asyncio.CancelledError
|
||||||
return await asyncio.get_event_loop().run_in_executor(
|
return await asyncio.get_event_loop().run_in_executor(
|
||||||
self.writer_executor, lambda: self.__run_transaction(fun, *args, **kwargs)
|
self.writer_executor, lambda: self.__run_transaction(fun, *args, **kwargs)
|
||||||
)
|
)
|
||||||
|
@ -230,6 +234,8 @@ class AIOSQLite:
|
||||||
self.read_ready.clear()
|
self.read_ready.clear()
|
||||||
try:
|
try:
|
||||||
async with self.write_lock:
|
async with self.write_lock:
|
||||||
|
if self._closing:
|
||||||
|
raise asyncio.CancelledError
|
||||||
return await asyncio.get_event_loop().run_in_executor(
|
return await asyncio.get_event_loop().run_in_executor(
|
||||||
self.writer_executor, self.__run_transaction_with_foreign_keys_disabled, fun, args, kwargs
|
self.writer_executor, self.__run_transaction_with_foreign_keys_disabled, fun, args, kwargs
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue