Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 64ee518

Browse files
committed
Fix the wake interval issue with calling _sleep (which kicks off another wake interval timer)
clihelper -> helper incompatibility
1 parent 84dff82 commit 64ee518

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

newrelic_plugin_agent/agent.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, args, operating_system):
4747
self._wake_interval = (self.config.application.get('wake_interval') or
4848
self.config.application.get('poll_interval') or
4949
self.WAKE_INTERVAL)
50-
self.next_wake_interval = self._wake_interval
50+
self.next_wake_interval = int(self._wake_interval)
5151
self.publish_queue = queue.Queue()
5252
self.threads = list()
5353
info = tuple([__version__] + list(self.system_platform))
@@ -103,7 +103,7 @@ def poll_plugin(self, plugin_name, plugin, config):
103103
'name': plugin_name,
104104
'plugin': plugin,
105105
'poll_interval':
106-
self.wake_interval})
106+
int(self._wake_interval)})
107107
thread.run()
108108
self.threads.append(thread)
109109

@@ -115,17 +115,20 @@ def process(self):
115115
"""
116116
start_time = time.time()
117117
self.start_plugin_polling()
118+
119+
# Sleep for a second while threads are running
118120
while self.threads_running:
119-
self._sleep()
121+
time.sleep(1)
122+
120123
self.threads = list()
121124
self.send_data_to_newrelic()
122125
duration = time.time() - start_time
123126
self.next_wake_interval = self._wake_interval - duration
124-
if self.next_wake_interval < 0:
127+
if self.next_wake_interval < 1:
125128
LOGGER.warning('Poll interval took greater than %i seconds',
126129
duration)
127-
self.next_wake_interval = self._wake_interval
128-
LOGGER.info('All stats processed in %.2f seconds, next wake in %.2f',
130+
self.next_wake_interval = int(self._wake_interval)
131+
LOGGER.info('Stats processed in %.2f seconds, next wake in %i seconds',
129132
duration, self.next_wake_interval)
130133

131134
def process_min_max_values(self, component):
@@ -229,7 +232,8 @@ def send_components(self, components, metrics):
229232
except requests.ConnectionError as error:
230233
LOGGER.error('Error reporting stats: %s', error)
231234

232-
def _get_plugin(self, plugin_path):
235+
@staticmethod
236+
def _get_plugin(plugin_path):
233237
"""Given a qualified class name (eg. foo.bar.Foo), return the class
234238
235239
:rtype: object

0 commit comments

Comments
 (0)