From 3bd62a86ffe1062f3854740fd2b0b5197f71ff81 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Mon, 15 Sep 2025 09:36:54 -0700 Subject: [PATCH 1/2] Implemented non-blocking web server for #91 --- pyfunnel/core.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) mode change 100755 => 100644 pyfunnel/core.py 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: From e2acfb39793304d5de11b11824f6bf90d54c2221 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Mon, 15 Sep 2025 09:40:12 -0700 Subject: [PATCH 2/2] Implemented non-blocking web server for #91 --- CHANGELOG.md | 4 ++++ pyfunnel/VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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