summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Fenn <fennm@deshawresearch.com>2013-10-10 14:21:07 -0400
committerMichael Fenn <fennm@deshawresearch.com>2013-10-10 14:21:07 -0400
commit9b8a2b6bfa0a0586f1c25358519c8d8db1260009 (patch)
tree68609fa1ca1c8fae0d5ce8a113676dad7a80559b
parent9871be0932869f35f33d3da22dae8db474e31cdd (diff)
downloadbcfg2-9b8a2b6bfa0a0586f1c25358519c8d8db1260009.tar.gz
bcfg2-9b8a2b6bfa0a0586f1c25358519c8d8db1260009.tar.bz2
bcfg2-9b8a2b6bfa0a0586f1c25358519c8d8db1260009.zip
Reporting: misc improvements to collector threading
1. Use a better convention for calling the threading.Thread constructor 2. Add docstring to ReportingStoreThread.run 3. Give the storage thread variable a better name
-rw-r--r--src/lib/Bcfg2/Reporting/Collector.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Reporting/Collector.py b/src/lib/Bcfg2/Reporting/Collector.py
index f348a60dc..febdfed13 100644
--- a/src/lib/Bcfg2/Reporting/Collector.py
+++ b/src/lib/Bcfg2/Reporting/Collector.py
@@ -29,15 +29,17 @@ class ReportingError(Exception):
class ReportingStoreThread(threading.Thread):
"""Thread for calling the storage backend"""
def __init__(self, interaction, storage, group=None, target=None,
- name=None, *args, **kwargs):
+ name=None, args=(), kwargs=None):
"""Initialize the thread with a reference to the interaction
as well as the storage engine to use"""
- threading.Thread.__init__(self, group, target, name, args, kwargs)
+ threading.Thread.__init__(self, group, target, name, args,
+ kwargs or dict())
self.interaction = interaction
self.storage = storage
self.logger = logging.getLogger('bcfg2-report-collector')
def run(self):
+ """Call the database storage procedure (aka import)"""
try:
start = time.time()
self.storage.import_interaction(self.interaction)
@@ -129,11 +131,11 @@ class ReportingCollector(object):
if not interaction:
continue
- t = ReportingStoreThread(interaction, self.storage)
+ store_thread = ReportingStoreThread(interaction, self.storage)
while len(threading.enumerate()) > 100:
self.logger.info("more than 100 threads running, sleeping")
time.sleep(1)
- t.start()
+ store_thread.start()
except (SystemExit, KeyboardInterrupt):
self.logger.info("Shutting down")
self.shutdown()