Skip to content

Commit

Permalink
refactor: make timeout configurable by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
trbtm committed Jul 9, 2024
1 parent 6f3c031 commit 241ac5c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions postgresql_watcher/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ def _create_subscription_process(
if start_listening:
self.start()

def start(self):
def start(
self,
timeout=20, # seconds
):
if not self.subscription_proces.is_alive():
# Start listening to messages
self.subscription_proces.start()
# And wait for the Process to be ready to listen for updates
# from PostgreSQL
timeout = 20 # seconds
timeout_time = time() + timeout
while True:
if self.parent_conn.poll():
Expand Down

0 comments on commit 241ac5c

Please sign in to comment.