Skip to content

Commit

Permalink
Remove traceback from logs and refine retryable_error worker
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinFoka committed Oct 29, 2024
1 parent 74077cd commit 8ef8194
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions examples/simple_worker/workers/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ def fail_three_times() -> None:
Simulates three consecutive failures by using an environment variable to track attempts.
Raises an exception on the first three executions and succeeds on the fourth.
"""
env_var_name: str = f"{self.__class__.__name__}_attempt_count"
attempt_count: int = int(os.getenv(env_var_name, 0))
env_var_name: str = f'{self.__class__.__name__}_attempt_count'
attempt_count: int = int(os.getenv(env_var_name, 'O'))

try:
if attempt_count < 3:
os.environ[env_var_name]: str = str(attempt_count + 1)
raise RuntimeError("Simulated failure")
if attempt_count < 3: # noqa: PLR2004
os.environ[env_var_name] = str(attempt_count + 1)
raise RuntimeError('Simulated failure')
else:
os.environ.pop(env_var_name, None)
except RuntimeError as e:
Expand Down
2 changes: 0 additions & 2 deletions frinx/common/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ def exception_response_handler(self, task: RawTaskIO, error: Exception, **kwargs

task_result.output = TaskOutput(**error_dict_with_output_path)

logger.error('%s error occurred: %s \n%s', error_name, error, str(traceback.format_exc()))

return task_result

def execute_wrapper(self, task: RawTaskIO) -> Any:
Expand Down

0 comments on commit 8ef8194

Please sign in to comment.