:py:class:`DiscFullPreventionWarning` and
:py:class:`DiscFullPreventionError`
"""
- super(DiscFillCheckerThread, self).__init__(name='discFillChck',
- daemon=True)
+ super(DiscFillCheckerThread, self).__init__(name='discFillChck')
+
+ self.daemon = True # works since python 2.6
+
# set variables
self.interval = interval
if decision_function is None:
internal helper called from __init__ and run
"""
+ if fs_state.name == 'tmpfs':
+ print('ignoring {0}'.format(fs_state))
+ return []
+
buf = None
try:
buf = self._bufs[fs_state.name]
sleep(self.interval)
fs_states = get_filesystem_fill_states()
for fs_state in fs_states:
+ # ignore tmpfs since is in memory or swap, so fill up is not
+ # as bad
+ if fs_state.name == 'tmpfs':
+ continue
+
fill_states = self._internal_state_buffer(fs_state)
# estimate time until full (i.e. when available == 0)
# call user-defined function to decide
min_time = None
- if any(times_until_empty > 0):
+ if any(time > 0 for time in times_until_empty):
min_time = min(time for time in times_until_empty
if time>0)
avg_time = calc_time_until_zero(fill_states[0],
@contextlib.contextmanager
-def disc_fill_checked(path):
- """ run test function while separate thread watches disc space """
+def disc_fill_checked(*args, **kwargs):
+ """ run test function while separate thread watches disc space
+
+ all args are forwarded to :py:class:`DiscFillCheckerThread` constructor
+ """
# todo: add args and forward
- DiscFillCheckerThread().start()
+ DiscFillCheckerThread(*args, **kwargs).start()
try:
yield