diff options
author | drebs <drebs@riseup.net> | 2017-09-17 12:08:25 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2017-09-17 15:50:55 -0300 |
commit | cfff46ff9becdbe5cf48816870e625ed253ecc57 (patch) | |
tree | 8d239e4499f559d86ed17ea3632008303b25d485 /testing/tests/responsiveness/watchdog.py | |
parent | f29abe28bd778838626d12fcabe3980a8ce4fa8c (diff) |
[refactor] move tests to root of repository
Tests entrypoint was in a testing/ subfolder in the root of the
repository. This was made mainly because we had some common files for
tests and we didn't want to ship them (files in testing/test_soledad,
which is itself a python package. This sometimes causes errors when
loading tests (it seems setuptools is confused with having one python
package in a subdirectory of another).
This commit moves the tests entrypoint to the root of the repository.
Closes: #8952
Diffstat (limited to 'testing/tests/responsiveness/watchdog.py')
-rw-r--r-- | testing/tests/responsiveness/watchdog.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/testing/tests/responsiveness/watchdog.py b/testing/tests/responsiveness/watchdog.py deleted file mode 100644 index 88f4fa67..00000000 --- a/testing/tests/responsiveness/watchdog.py +++ /dev/null @@ -1,53 +0,0 @@ -from twisted.internet import defer, reactor -from twisted.internet.task import LoopingCall -from twisted.internet.threads import deferToThread - - -class Watchdog(object): - - DEBUG = False - - def __init__(self, delay=0.01): - self.delay = delay - self.loop_call = LoopingCall.withCount(self.watch) - self.blocked = 0 - self.checks = [] - self.d = None - - def start(self): - self.debug("\n[watchdog] starting") - self.loop_call.start(self.delay) - self.d = defer.Deferred() - return self.d - - def watch(self, count): - self.debug("[watchdog] watching (%d)" % count) - if (self.loop_call.running): - self.checks.append(deferToThread(self._check, count)) - - def _check(self, count): - # self.debug("[watchdog] _checking (%d)" % count) - if count > 1: - self.blocked += count - - def stop(self): - # delay the actual stop so we make sure at least one check watch will - # run in the reactor. - reactor.callLater(2 * self.delay, self._stop) - - @defer.inlineCallbacks - def _stop(self): - if not self.loop_call.running: - return - - self.loop_call.stop() - yield defer.gatherResults(self.checks) - self.d.callback(None) - - @property - def seconds_blocked(self): - return self.blocked * self.delay - - def debug(self, s): - if self.DEBUG: - print(s) |