Skip to content

Commit

Permalink
chg: containers (podman) - stats iteration interval longer
Browse files Browse the repository at this point in the history
fix #2390

note: tmp fix
Proper sol - containers/podman-py#266
  • Loading branch information
RazCrimson committed May 13, 2023
1 parent b1da4f6 commit 83fc2a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion glances/plugins/containers/glances_podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, pod_manager):
# Threaded Streamer
# Temporary patch to get podman extension working
stats_iterable = (pod_manager.stats(decode=True) for _ in iter(int, 1))
self._streamer = StatsStreamer(stats_iterable, initial_stream_value={})
self._streamer = StatsStreamer(stats_iterable, initial_stream_value={}, sleep_duration=2)

def _log_debug(self, msg, exception=None):
logger.debug("containers (Podman): Pod Manager - {} ({})".format(msg, exception))
Expand Down
6 changes: 4 additions & 2 deletions glances/plugins/containers/stats_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StatsStreamer:
Use `StatsStreamer.stats` to access the latest streamed results
"""

def __init__(self, iterable, initial_stream_value=None):
def __init__(self, iterable, initial_stream_value=None, sleep_duration=0.1):
"""
iterable: an Iterable instance that needs to be streamed
"""
Expand All @@ -34,6 +34,8 @@ def __init__(self, iterable, initial_stream_value=None):
self.result_lock = threading.Lock()
# Last result streamed time (initial val 0)
self._last_update_time = 0
# Time to sleep before next iteration
self._sleep_duration = sleep_duration

self._thread.start()

Expand All @@ -56,7 +58,7 @@ def _stream_results(self):
self._raw_result = res
self._post_update_hook()

time.sleep(0.1)
time.sleep(self._sleep_duration)
if self.stopped():
break

Expand Down

0 comments on commit 83fc2a2

Please sign in to comment.