Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statistics can be incorrectly initialized inside Temporal contexts #507

Open
2timesjay opened this issue Jan 14, 2025 · 1 comment
Open

Comments

@2timesjay
Copy link

2timesjay commented Jan 14, 2025

Within temporal, an asynchronous python workflow manager, statistics are not being correctly initialized. Given that statistics are on a local thread, my best guess is that a different thread is calling "next_action" than the one that initializes the AsyncRetrying object.

Temporal has a custom AsyncEventLoop, and a function to suspend a job and then "replay" it up to a point, which further complicates its interactions here.

My proposed solution is to either make statistics a normal attribute (I assume this would be pretty delicate), or to ensure we handle uninitialized elements of "statistics" robustly (see PR below)

{
  <...rest of big nested stack trace...>
    raise ApplicationError(
      "cause": {
        "message": "'idle_for'",
        "stackTrace": "  File "/app/venv/lib/python3.10/site-packages/ml/features/workflows.py", line 509, in online_ingest_feature_source
    async for attempt in retry_context:

  File "/app/venv/lib/python3.10/site-packages/tenacity/asyncio/__init__.py", line 166, in __anext__
    do = await self.iter(retry_state=self._retry_state)

  File "/app/venv/lib/python3.10/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
    result = await action(retry_state)

  File "/app/venv/lib/python3.10/site-packages/tenacity/_utils.py", line 99, in inner
    return call(*args, **kwargs)

  File "/app/venv/lib/python3.10/site-packages/tenacity/__init__.py", line 428, in next_action
    self.statistics["idle_for"] += sleep
",
        "applicationFailureInfo": {
          "type": "KeyError"
        }
      },
      "applicationFailureInfo": {}
    },
    "applicationFailureInfo": {}
  },
  "applicationFailureInfo": {}
}
@2timesjay
Copy link
Author

PR: #508

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant