Add option to disable thread in tryton
As shown in #11767 on some platform the Python threading does not work well with Gtk. So it is good to have the option to disable it at the cost of less performance.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add option to disable thread
|
||||
* Remove support for Python 3.7
|
||||
* Add support for Python 3.11
|
||||
* Save and Restore tree state on List Form
|
||||
|
||||
@@ -25,6 +25,8 @@ CHANNELS = [
|
||||
|
||||
|
||||
def listen(connection):
|
||||
if not CONFIG['thread']:
|
||||
return
|
||||
listener = threading.Thread(
|
||||
target=_listen, args=(connection,), daemon=True)
|
||||
listener.start()
|
||||
|
||||
@@ -97,6 +97,9 @@ class ConfigManager(object):
|
||||
help=_("specify the login user"))
|
||||
parser.add_option("-s", "--server", dest="host",
|
||||
help=_("specify the server hostname:port"))
|
||||
parser.add_option(
|
||||
'--no-thread', default=True, action='store_false', dest='thread',
|
||||
help=_("disable thread usage"))
|
||||
opt, self.arguments = parser.parse_args()
|
||||
self.rcfile = opt.config or os.path.join(
|
||||
get_config_dir(), 'tryton.conf')
|
||||
@@ -125,6 +128,7 @@ class ConfigManager(object):
|
||||
for arg in ['login', 'host']:
|
||||
if getattr(opt, arg):
|
||||
self.options['login.' + arg] = getattr(opt, arg)
|
||||
self.options['thread'] = opt.thread
|
||||
|
||||
def save(self):
|
||||
try:
|
||||
|
||||
+19
-13
@@ -522,19 +522,25 @@ class Main(Gtk.Application):
|
||||
except RPCException:
|
||||
prefs = {}
|
||||
|
||||
threads = []
|
||||
for target in (
|
||||
common.IconFactory.load_icons,
|
||||
common.MODELACCESS.load_models,
|
||||
common.MODELHISTORY.load_history,
|
||||
common.MODELNOTIFICATION.load_names,
|
||||
common.VIEW_SEARCH.load_searches,
|
||||
):
|
||||
t = threading.Thread(target=target)
|
||||
threads.append(t)
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
targets = [
|
||||
common.IconFactory.load_icons,
|
||||
common.MODELACCESS.load_models,
|
||||
common.MODELHISTORY.load_history,
|
||||
common.MODELNOTIFICATION.load_names,
|
||||
common.VIEW_SEARCH.load_searches,
|
||||
]
|
||||
if CONFIG['thread']:
|
||||
threads = []
|
||||
for target in targets:
|
||||
t = threading.Thread(target=target)
|
||||
threads.append(t)
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
else:
|
||||
for target in targets:
|
||||
target()
|
||||
|
||||
if prefs and 'language_direction' in prefs:
|
||||
translate.set_language_direction(prefs['language_direction'])
|
||||
CONFIG['client.language_direction'] = \
|
||||
|
||||
@@ -286,9 +286,13 @@ class DBListEditor(object):
|
||||
|
||||
def refresh_databases(self, host, port):
|
||||
self.dbs_updated = threading.Event()
|
||||
threading.Thread(target=self.refresh_databases_start,
|
||||
args=(host, port)).start()
|
||||
GLib.timeout_add(100, self.refresh_databases_end, host, port)
|
||||
if CONFIG['thread']:
|
||||
threading.Thread(target=self.refresh_databases_start,
|
||||
args=(host, port)).start()
|
||||
GLib.timeout_add(100, self.refresh_databases_end, host, port)
|
||||
else:
|
||||
self.refresh_databases_start(host, port)
|
||||
self.refresh_databases_end(host, port)
|
||||
|
||||
def refresh_databases_start(self, host, port):
|
||||
dbs = None
|
||||
|
||||
Reference in New Issue
Block a user