From 6fd89b5001ccc4e6782294489c40464cfebbf32c Mon Sep 17 00:00:00 2001 From: stuartbeattie84 <62883733+stuartbeattie84@users.noreply.github.com> Date: Tue, 17 May 2022 12:12:08 +0100 Subject: [PATCH] fix: made should_reload into a blocking call (#21) * Made should_reload into a blocking call * Removed should_reload() unit test, as this will now wait forever. --- postgresql_watcher/watcher.py | 3 +-- tests/test_postgresql_watcher.py | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/postgresql_watcher/watcher.py b/postgresql_watcher/watcher.py index 4895e15..2f5d0ee 100644 --- a/postgresql_watcher/watcher.py +++ b/postgresql_watcher/watcher.py @@ -87,7 +87,6 @@ def create_subscriber_process( ) if start_process: p.start() - self.should_reload() return p def set_update_callback(self, fn_name: Callable): @@ -113,7 +112,7 @@ def update(self): def should_reload(self): try: - if self.parent_conn.poll(): + if self.parent_conn.poll(None): message = self.parent_conn.recv() print(f"message:{message}") return True diff --git a/tests/test_postgresql_watcher.py b/tests/test_postgresql_watcher.py index 537805d..fa0356a 100644 --- a/tests/test_postgresql_watcher.py +++ b/tests/test_postgresql_watcher.py @@ -39,9 +39,6 @@ def test_pg_watcher_init(self): def test_update_pg_watcher(self): assert pg_watcher.update() is True - def test_not_reload(self): - assert not pg_watcher.should_reload() - def test_default_update_callback(self): assert pg_watcher.update_callback() is None