Skip to content

Commit d03aa7c

Browse files
author
Lee Miller
committed
Add a timeout for sql_ready waiting, exit from object processor if reached
1 parent e4488ba commit d03aa7c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/class_objectProcessor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# pylint: disable=too-many-branches,too-many-statements
77
import hashlib
88
import logging
9+
import os
910
import random
1011
import subprocess # nosec B404
1112
import threading
@@ -28,7 +29,8 @@
2829
)
2930
from bmconfigparser import config
3031
from fallback import RIPEMD160Hash
31-
from helper_sql import sql_ready, SqlBulkExecute, sqlExecute, sqlQuery
32+
from helper_sql import (
33+
sql_ready, sql_timeout, SqlBulkExecute, sqlExecute, sqlQuery)
3234
from network import bmproto, knownnodes
3335
from network.node import Peer
3436
from tr import _translate
@@ -44,7 +46,9 @@ class objectProcessor(threading.Thread):
4446
def __init__(self):
4547
threading.Thread.__init__(self, name="objectProcessor")
4648
random.seed()
47-
sql_ready.wait()
49+
if sql_ready.wait(sql_timeout) is False:
50+
logger.fatal('SQL thread is not started in %s sec', sql_timeout)
51+
os._exit(1)
4852
shared.reloadMyAddressHashes()
4953
shared.reloadBroadcastSendersForWhichImWatching()
5054
# It may be the case that the last time Bitmessage was running,

src/helper_sql.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
sql_ready = threading.Event()
3434
"""set by `.threads.sqlThread` when ready for processing (after
3535
initialization is done)"""
36+
sql_timeout = 60
37+
"""timeout for waiting for sql_ready in seconds"""
3638

3739

3840
def sqlQuery(sql_statement, *args):

0 commit comments

Comments
 (0)