master - lvmdbusd: Stop using threads for job wait
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96118a2508e1cd3aaf5ba7a0129ff8ecc7ac4af2 Commit: 96118a2508e1cd3aaf5ba7a0129ff8ecc7ac4af2 Parent: 95abadd13c468b56612c1966d28daddfdeee6e2e Author: Tony Asleson <[email protected]> AuthorDate: Wed Nov 2 14:14:56 2016 -0500 Committer: Tony Asleson <[email protected]> CommitterDate: Wed Nov 2 16:39:13 2016 -0500
lvmdbusd: Stop using threads for job wait
Instead of creating a thread to handle the case where a client is calling job.Wait, we will utilize a timer. This significantly reduces the number of threads that get created and destroyed while the service is running.
--- daemons/lvmdbusd/background.py | 29 +------------- daemons/lvmdbusd/job.py | 83 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 31 deletions(-)
daemons/lvmdbusd/background.py +1 -28
@@ -12,8 +12,7 @@ import subprocess from . import cfg from .cmdhandler import options_to_cli_args import dbus -from .utils import pv_range_append, pv_dest_ranges, log_error, log_debug, \ - mt_async_result +from .utils import pv_range_append, pv_dest_ranges, log_error, log_debug import traceback import os
@@ -184,29 +183,3 @@ def add(command, reporting_job): with _rlock: _thread_list.append(t) - -def wait_thread(job, timeout, cb, cbe): - # We need to put the wait on it's own thread, so that we don't block the - # entire dbus queue processing thread - try: - mt_async_result(cb, job.state.Wait(timeout)) - except Exception as e: - mt_async_result(cbe, "Wait exception: %s" % str(e)) - return 0 - - -def add_wait(job, timeout, cb, cbe): - - if timeout == 0: - # Users are basically polling, do not create thread - mt_async_result(cb, job.Complete) - else: - t = threading.Thread( - target=wait_thread, - name="thread job.Wait: %s" % job.dbus_object_path(), - args=(job, timeout, cb, cbe) - ) - - t.start() - with _rlock: - _thread_list.append(t)
daemons/lvmdbusd/job.py +80 -3
117 lines not on this page · raw message