Add a timeout for sql_ready waiting, exit from object processor if reached
This commit is contained in:
parent
e4488ba370
commit
d03aa7c412
|
@ -6,6 +6,7 @@ processes the network objects
|
||||||
# pylint: disable=too-many-branches,too-many-statements
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import subprocess # nosec B404
|
import subprocess # nosec B404
|
||||||
import threading
|
import threading
|
||||||
|
@ -28,7 +29,8 @@ from addresses import (
|
||||||
)
|
)
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from fallback import RIPEMD160Hash
|
from fallback import RIPEMD160Hash
|
||||||
from helper_sql import sql_ready, SqlBulkExecute, sqlExecute, sqlQuery
|
from helper_sql import (
|
||||||
|
sql_ready, sql_timeout, SqlBulkExecute, sqlExecute, sqlQuery)
|
||||||
from network import bmproto, knownnodes
|
from network import bmproto, knownnodes
|
||||||
from network.node import Peer
|
from network.node import Peer
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
@ -44,7 +46,9 @@ class objectProcessor(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self, name="objectProcessor")
|
threading.Thread.__init__(self, name="objectProcessor")
|
||||||
random.seed()
|
random.seed()
|
||||||
sql_ready.wait()
|
if sql_ready.wait(sql_timeout) is False:
|
||||||
|
logger.fatal('SQL thread is not started in %s sec', sql_timeout)
|
||||||
|
os._exit(1)
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
shared.reloadBroadcastSendersForWhichImWatching()
|
shared.reloadBroadcastSendersForWhichImWatching()
|
||||||
# It may be the case that the last time Bitmessage was running,
|
# It may be the case that the last time Bitmessage was running,
|
||||||
|
|
|
@ -33,6 +33,8 @@ sql_available = False
|
||||||
sql_ready = threading.Event()
|
sql_ready = threading.Event()
|
||||||
"""set by `.threads.sqlThread` when ready for processing (after
|
"""set by `.threads.sqlThread` when ready for processing (after
|
||||||
initialization is done)"""
|
initialization is done)"""
|
||||||
|
sql_timeout = 60
|
||||||
|
"""timeout for waiting for sql_ready in seconds"""
|
||||||
|
|
||||||
|
|
||||||
def sqlQuery(sql_statement, *args):
|
def sqlQuery(sql_statement, *args):
|
||||||
|
|
Reference in New Issue
Block a user