diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f61c04..c15d131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## Version 1.0.3 + +- Changed web server to be non-blocking if timeout is set to 0. + ## Version 1.0.2 - Bug fixes diff --git a/pyfunnel/VERSION b/pyfunnel/VERSION index 6d7de6e..21e8796 100644 --- a/pyfunnel/VERSION +++ b/pyfunnel/VERSION @@ -1 +1 @@ -1.0.2 +1.0.3 diff --git a/pyfunnel/core.py b/pyfunnel/core.py old mode 100755 new mode 100644 index 66b8307..0721a4f --- a/pyfunnel/core.py +++ b/pyfunnel/core.py @@ -102,9 +102,9 @@ def wait_until(somepredicate, timeout, period=0.1, *args, **kwargs): must_end = time.time() + timeout while time.time() < must_end: if somepredicate(*args, **kwargs): - return True + return time.sleep(period) - return False + return def exit_test(logger, list_files=None): @@ -456,9 +456,13 @@ def browse(self, *args, **kwargs): else: raise KeyboardInterrupt - print('Server will run for {} s (or until KeyboardInterrupt) at:\n'.format(timeout) + \ - 'http://localhost:{}/funnel'.format(self.server_port)) - wait_until(exit_test, timeout, 0.1, self.logger, *args) + if timeout < 0.00001: + worker = threading.Thread(target=wait_until(exit_test, timeout, 0.1, self.logger, *args)) + worker.start() + else: + print('Server will run for {} s (or until KeyboardInterrupt) at:\n'.format(timeout) + \ + 'http://localhost:{}/funnel'.format(self.server_port)) + wait_until(exit_test, timeout, 0.1, self.logger, *args) except KeyboardInterrupt: print('KeyboardInterrupt') finally: