Skip to content

Commit

Permalink
Merge pull request #16 from canonical/unpin-protobuf-version
Browse files Browse the repository at this point in the history
Unpin 'protobuf' version and add better worker error logging.
  • Loading branch information
mertalpt authored Apr 16, 2024
2 parents 5aaa90a + 23034c1 commit 1673e65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/resources/check_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def check_worker_status():
status = status_file.read().strip()
logger.info(f"Async status: {status}")

if "Error" in status:
exit_code = 1
else:
if status.startswith("Success"):
exit_code = 0
else:
exit_code = 1
except FileNotFoundError:
logger.error("Status file not found. Worker is not running.")
exit_code = 1
Expand Down
1 change: 0 additions & 1 deletion src/resources/worker-dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
temporal-lib-py==1.1.3
protobuf==3.20.0
wheel==0.41.2
8 changes: 7 additions & 1 deletion src/resources/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import asyncio
import glob
import inspect
import logging
import os
import sys
import traceback
from importlib import import_module

from temporallib.auth import (
Expand All @@ -23,6 +25,9 @@
from temporallib.worker import SentryOptions, Worker, WorkerOptions


logger = logging.getLogger(__name__)


def _get_auth_header():
"""Get auth options based on provider.
Expand Down Expand Up @@ -156,7 +161,8 @@ async def run_worker(unpacked_file_name, module_name):
except Exception as e:
# If an error occurs, write the error message to the status file
with open("worker_status.txt", "w") as status_file:
status_file.write(f"Error: {e}")
logger.exception("Error in the workflow:")
traceback.print_exception(type(e), e, e.__traceback__, file=status_file)


if __name__ == "__main__": # pragma: nocover
Expand Down

0 comments on commit 1673e65

Please sign in to comment.