temporalio / temporalio/samples-python
[Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity.
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 367
- Forks
- 121
- Merge moyen
- 3 j 20 h
- PR mergées (30 j)
- 11
Description
What are you really trying to do?
When using
@register_activity
@activity.defn
async def get_http_response(URL: str) -> dict:
async with httpx.AsyncClient() as client:
return await client.get(url)
Describe the bug
We get the following error:
RestrictedWorkflowAccessError
Cannot access threading.local.mro_entries from inside a workflow. If this is code from a module not used in a workflow or known to only be used deterministically from a workflow, mark the import as pass through.
Minimal Reproduction
I believe the workflow sandbox is reactivated before the asynclient __aexit__ code.
Which leads to Temporal thinking its execution is happening in the workflow scope rather than within the activity one.
Environment/Versions
temporal==1.10.0
Additional context
I'm trying to split it in two calls to make it work:
@register_activity
@activity.defn
async def get_http_response(URL: str) -> dict:
async with httpx.AsyncClient() as client:
response = await client.get(url)
return response
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduire l’exemple minimal d’activité de l’issue avec temporal==1.10.0 et httpx.AsyncClient, puis vérifier si les restrictions du sandbox du workflow sont réactivées pendant aexit du gestionnaire de contexte asynchrone. Le travail est considéré comme terminé lorsque l’activité peut retourner la réponse HTTP sans lever RestrictedWorkflowAccessError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100