Skip to content

Commit

Permalink
More logging and corrected some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredeen committed Aug 20, 2024
1 parent c196b01 commit bedddba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions serve_event_listener/event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def listen(self) -> None:

def check_status(self) -> bool:
"""
Checks the status of the EventListener.
Checks the status of the Serve API.
Returns:
- bool: True if the status is okay, False otherwise.
Expand Down Expand Up @@ -291,10 +291,10 @@ def post(

def get(self, url: str, headers: Union[None, dict] = None):
"""
Send a POST request to the specified URL with the provided data and token.
Send a GET request to the specified URL with the provided data and token.
Args:
url (str): The URL to send the POST request to.
url (str): The URL to send the GET request to.
data (dict): The data to be included in the POST request.
header (None or dict): header for the request.
Expand Down
3 changes: 3 additions & 0 deletions serve_event_listener/status_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def update_or_create_status(
Returns:
Dict: Updated status data.
"""
logger.debug(f"Release {release}. Status data before update:{status_data}. \
release in status data? {release not in status_data}. \
creation_timestamp={creation_timestamp}, deletion_timestamp={deletion_timestamp}")
if (
release not in status_data
or creation_timestamp >= status_data[release]["creation_timestamp"]
Expand Down
9 changes: 7 additions & 2 deletions serve_event_listener/status_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ def add(self, status_data):
def process(self):
while not self.stop_event.is_set():
try:
status_data = self.queue.get(timeout=2) # Wait for 1 second
status_data = self.queue.get(timeout=2) # Wait for 2 seconds

release = status_data["release"]
new_status = status_data["new-status"]
if new_status == "Deleted":
logger.info(f"Processing release: {release}. New status is Deleted!")

self.post_handler(
data=status_data,
Expand All @@ -35,7 +40,7 @@ def process(self):

self.queue.task_done()

logger.debug("Processing queue successfully")
logger.debug(f"Processed queue successfully of release {release}, new status={new_status}")
except queue.Empty:
pass # Continue looping if the queue is empty

Expand Down

0 comments on commit bedddba

Please sign in to comment.