From c914ba75a1829de4abccd8efc137ce25da04ee50 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Wed, 9 Sep 2015 14:58:39 -0400 Subject: [PATCH] identify thread numbers --- poller-service.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/poller-service.py b/poller-service.py index 342aaa6ad..8cfa1ee40 100755 --- a/poller-service.py +++ b/poller-service.py @@ -233,7 +233,7 @@ next_update = datetime.now() + timedelta(minutes=1) devices_scanned = 0 -def poll_worker(): +def poll_worker(thread_id): global dev_query global devices_scanned db = DB() @@ -244,14 +244,14 @@ def poll_worker(): continue if next_poll and next_poll > datetime.now(): - log.debug('DEBUG: Sleeping until {0} before polling {1}'.format(next_poll, device_id)) + log.debug('DEBUG: Thread {0} Sleeping until {1} before polling {2}'.format(thread_id, next_poll, device_id)) sleep_until(next_poll) action = 'poll' if (not next_discovery or next_discovery < datetime.now()) and status == 1: action = 'discovery' - log.debug('DEBUG: Starting {0} of device {1}'.format(action, device_id)) + log.debug('DEBUG: Thread {0} Starting {1} of device {2}'.format(thread_id, action, device_id)) devices_scanned += 1 db.query('UPDATE devices SET last_poll_attempted = NOW() WHERE device_id = {0}'.format(device_id)) @@ -270,9 +270,9 @@ def poll_worker(): subprocess.check_call(command, shell=True) elapsed_time = int(time.time() - start_time) if elapsed_time < 300: - log.debug("DEBUG: worker finished %s of device %s in %s seconds" % (action, device_id, elapsed_time)) + log.debug("DEBUG: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time)) else: - log.warning("WARNING: worker finished %s of device %s in %s seconds" % (action, device_id, elapsed_time)) + log.warning("WARNING: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time)) except (KeyboardInterrupt, SystemExit): raise except: @@ -283,7 +283,7 @@ def poll_worker(): t = [] for i in range(0, amount_of_workers): - t.append(threading.Thread(target=poll_worker)) + t.append(threading.Thread(target=poll_worker, args=[i])) t[i].start()