temporalio / temporalio/samples-python

[Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity.

オープン
#192 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug
主要言語
Python
スター
367
フォーク
121
平均マージ
3日 20時間
マージ済み PR(30日)
11

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

temporal==1.10.0 と httpx.AsyncClient を使用して issue の最小アクティビティ例を再現し、その後、非同期コンテキストマネージャーの aexit 中に workflow sandbox の制限が再有効化されるかどうかを調査します。アクティビティが RestrictedWorkflowAccessError を発生させずに HTTP レスポンスを返せれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。