Bugfixes
This commit is contained in:
parent
d2fe721072
commit
a92bbbbcbf
5 changed files with 60 additions and 11 deletions
|
@ -488,7 +488,7 @@ class App:
|
||||||
LOG.debug(f"_start_threads init: {te()!r}")
|
LOG.debug(f"_start_threads init: {te()!r}")
|
||||||
|
|
||||||
# starting threads for tox iterate and toxav iterate
|
# starting threads for tox iterate and toxav iterate
|
||||||
self._main_loop = threads.ToxIterateThread(self._tox)
|
self._main_loop = threads.ToxIterateThread(self._tox, self)
|
||||||
self._main_loop.start()
|
self._main_loop.start()
|
||||||
|
|
||||||
self._av_loop = threads.ToxAVIterateThread(self._tox.AV)
|
self._av_loop = threads.ToxAVIterateThread(self._tox.AV)
|
||||||
|
@ -849,7 +849,7 @@ class App:
|
||||||
self.test_net()
|
self.test_net()
|
||||||
self._ms.log_console()
|
self._ms.log_console()
|
||||||
|
|
||||||
def test_net(self, lElts=None, oThread=None, iMax=4):
|
def test_net(self, oThread=None, iMax=4):
|
||||||
|
|
||||||
LOG.debug("test_net " +self._oArgs.network)
|
LOG.debug("test_net " +self._oArgs.network)
|
||||||
# bootstrap
|
# bootstrap
|
||||||
|
@ -905,6 +905,9 @@ class App:
|
||||||
LOG.trace(f"Connected status #{i}: {status!r}")
|
LOG.trace(f"Connected status #{i}: {status!r}")
|
||||||
self.loop(2)
|
self.loop(2)
|
||||||
|
|
||||||
|
global iLAST_CONN
|
||||||
|
iLAST_CONN = time.time()
|
||||||
|
|
||||||
def _test_env(self):
|
def _test_env(self):
|
||||||
_settings = self._settings
|
_settings = self._settings
|
||||||
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
||||||
|
|
|
@ -3,7 +3,6 @@ from sqlite3 import connect
|
||||||
import os.path
|
import os.path
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
|
|
||||||
# LOG=util.log
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.db')
|
LOG = logging.getLogger('app.db')
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
||||||
from history.history_logs_generators import *
|
from history.history_logs_generators import *
|
||||||
|
|
||||||
|
global LOG
|
||||||
|
import logging
|
||||||
|
LOG = logging.getLogger('app.db')
|
||||||
|
|
||||||
class History:
|
class History:
|
||||||
|
|
||||||
def __init__(self, contact_provider, db, settings, main_screen, messages_items_factory):
|
def __init__(self, contact_provider, db, settings, main_screen, messages_items_factory):
|
||||||
|
|
|
@ -6,6 +6,7 @@ from PyQt5 import QtCore
|
||||||
|
|
||||||
from bootstrap.bootstrap import *
|
from bootstrap.bootstrap import *
|
||||||
from bootstrap.bootstrap import download_nodes_list
|
from bootstrap.bootstrap import download_nodes_list
|
||||||
|
from wrapper.toxcore_enums_and_consts import TOX_USER_STATUS, TOX_CONNECTION
|
||||||
import wrapper_tests.support_testing as ts
|
import wrapper_tests.support_testing as ts
|
||||||
from utils import util
|
from utils import util
|
||||||
|
|
||||||
|
@ -36,6 +37,9 @@ def LOG_INFO(l): print('INFO+ '+l)
|
||||||
def LOG_DEBUG(l): print('DBUG+ '+l)
|
def LOG_DEBUG(l): print('DBUG+ '+l)
|
||||||
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
||||||
|
|
||||||
|
iLAST_CONN = 0
|
||||||
|
iLAST_DELTA = 60
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Base threads
|
# Base threads
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -117,7 +121,7 @@ class InitThread(BaseThread):
|
||||||
threading.Timer(1.0,
|
threading.Timer(1.0,
|
||||||
self._app.test_net,
|
self._app.test_net,
|
||||||
args=list(),
|
args=list(),
|
||||||
kwargs=dict(lElts=None, oThread=self, iMax=2)
|
kwargs=dict(oThread=self, iMax=4)
|
||||||
).start()
|
).start()
|
||||||
|
|
||||||
if self._is_first_start:
|
if self._is_first_start:
|
||||||
|
@ -136,9 +140,10 @@ class InitThread(BaseThread):
|
||||||
|
|
||||||
class ToxIterateThread(BaseQThread):
|
class ToxIterateThread(BaseQThread):
|
||||||
|
|
||||||
def __init__(self, tox):
|
def __init__(self, tox, app=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._tox = tox
|
self._tox = tox
|
||||||
|
self._app = app
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
LOG_DEBUG('ToxIterateThread run: ')
|
LOG_DEBUG('ToxIterateThread run: ')
|
||||||
|
@ -150,7 +155,30 @@ class ToxIterateThread(BaseQThread):
|
||||||
# Fatal Python error: Segmentation fault
|
# Fatal Python error: Segmentation fault
|
||||||
LOG_ERROR(f"ToxIterateThread run: {e}")
|
LOG_ERROR(f"ToxIterateThread run: {e}")
|
||||||
else:
|
else:
|
||||||
sleep(iMsec / 1000)
|
sleep(iMsec / 1000.0)
|
||||||
|
|
||||||
|
global iLAST_CONN
|
||||||
|
if not iLAST_CONN:
|
||||||
|
iLAST_CONN = time.time()
|
||||||
|
# TRAC> TCP_common.c#203:read_TCP_packet recv buffer has 0 bytes, but requested 10 bytes
|
||||||
|
|
||||||
|
# and segv
|
||||||
|
if \
|
||||||
|
time.time() - iLAST_CONN > iLAST_DELTA and \
|
||||||
|
ts.bAreWeConnected() and \
|
||||||
|
self._tox.self_get_status() == TOX_USER_STATUS['NONE'] and \
|
||||||
|
self._tox.self_get_connection_status() == TOX_CONNECTION['NONE']:
|
||||||
|
iLAST_CONN = time.time()
|
||||||
|
LOG_INFO(f"ToxIterateThread calling test_net")
|
||||||
|
if True:
|
||||||
|
invoke_in_main_thread(
|
||||||
|
self._app.test_net, oThread=self, iMax=2)
|
||||||
|
else:
|
||||||
|
threading.Timer(1.0,
|
||||||
|
self._app.test_net,
|
||||||
|
args=list(),
|
||||||
|
kwargs=dict(lElts=None, oThread=self, iMax=2)
|
||||||
|
).start()
|
||||||
|
|
||||||
|
|
||||||
class ToxAVIterateThread(BaseQThread):
|
class ToxAVIterateThread(BaseQThread):
|
||||||
|
|
|
@ -17,6 +17,20 @@ from ctypes import *
|
||||||
from utils import util
|
from utils import util
|
||||||
from utils import ui as util_ui
|
from utils import ui as util_ui
|
||||||
|
|
||||||
|
# callbacks can be called in any thread so were being careful
|
||||||
|
# tox.py can be called by callbacks
|
||||||
|
def LOG_ERROR(a): print('EROR> '+a)
|
||||||
|
def LOG_WARN(a): print('WARN> '+a)
|
||||||
|
def LOG_INFO(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20
|
||||||
|
if bVERBOSE: print('INFO> '+a)
|
||||||
|
def LOG_DEBUG(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10-1
|
||||||
|
if bVERBOSE: print('DBUG> '+a)
|
||||||
|
def LOG_TRACE(a):
|
||||||
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10
|
||||||
|
if bVERBOSE: print('TRAC> '+a)
|
||||||
|
|
||||||
def tox_log_cb(iTox, level, file, line, func, message, *args):
|
def tox_log_cb(iTox, level, file, line, func, message, *args):
|
||||||
"""
|
"""
|
||||||
* @param level The severity of the log message.
|
* @param level The severity of the log message.
|
||||||
|
@ -42,7 +56,7 @@ def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
:return: new tox instance
|
:return: new tox instance
|
||||||
"""
|
"""
|
||||||
if not settings:
|
if not settings:
|
||||||
LOG.warn("tox_factory using get_default_settings")
|
LOG_WARN("tox_factory using get_default_settings")
|
||||||
settings = user_data.settings.Settings.get_default_settings()
|
settings = user_data.settings.Settings.get_default_settings()
|
||||||
else:
|
else:
|
||||||
user_data.settings.clean_settings(settings)
|
user_data.settings.clean_settings(settings)
|
||||||
|
@ -88,13 +102,14 @@ def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
tox_options._options_pointer,
|
tox_options._options_pointer,
|
||||||
tox_options.self_logger_cb)
|
tox_options.self_logger_cb)
|
||||||
else:
|
else:
|
||||||
logging.warn("No tox_options._options_pointer to add self_logger_cb" )
|
logging_WARN("No tox_options._options_pointer to add self_logger_cb" )
|
||||||
|
|
||||||
retval = wrapper.tox.Tox(tox_options)
|
retval = wrapper.tox.Tox(tox_options)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if app and hasattr(app, '_log'):
|
if app and hasattr(app, '_log'):
|
||||||
app._log(f"ERROR: wrapper.tox.Tox failed: {e}")
|
pass
|
||||||
LOG.warn(traceback.format_exc())
|
LOG_ERROR(f"wrapper.tox.Tox failed: {e}")
|
||||||
|
LOG_WARN(traceback.format_exc())
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if app and hasattr(app, '_log'):
|
if app and hasattr(app, '_log'):
|
||||||
|
|
Loading…
Reference in a new issue