Title: [Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity. · Issue #192 · temporalio/samples-python · GitHub
Open Graph Title: [Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity. · Issue #192 · temporalio/samples-python
X Title: [Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity. · Issue #192 · temporalio/samples-python
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 er...
Open Graph 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) ...
X 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(ur...
Opengraph URL: https://github.com/temporalio/samples-python/issues/192
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] RestrictedWorkflowAccessError on async context manager in return close of an activity.","articleBody":"### What are you really trying to do?\n\nWhen using \n\n```\n@register_activity\n@activity.defn\nasync def get_http_response(URL: str) -\u003e dict:\n async with httpx.AsyncClient() as client:\n return await client.get(url)\n```\n\n### Describe the bug\n\nWe get the following error:\n\n\u003e **RestrictedWorkflowAccessError**\n\u003e 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.\n\n### Minimal Reproduction\n\nI believe the workflow sandbox is reactivated before the asynclient `__aexit__` code.\nWhich leads to Temporal thinking its execution is happening in the workflow scope rather than within the activity one.\n\n### Environment/Versions\n\ntemporal==1.10.0\n\n### Additional context\n\nI'm trying to split it in two calls to make it work:\n\n```\n@register_activity\n@activity.defn\nasync def get_http_response(URL: str) -\u003e dict:\n async with httpx.AsyncClient() as client:\n response = await client.get(url)\n return response\n```\n","author":{"url":"https://github.com/Natim","@type":"Person","name":"Natim"},"datePublished":"2025-06-09T09:14:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/192/samples-python/issues/192"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:20a7c8fe-54ea-92e7-89b7-115eec8cb439 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8E0:1CFD94:FC5EB8:15B374C:6A4CA198 |
| html-safe-nonce | acd32fced50029172991e13d1ada0a843a3687c198e6e90085e37e531ae1e541 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEUwOjFDRkQ5NDpGQzVFQjg6MTVCMzc0Qzo2QTRDQTE5OCIsInZpc2l0b3JfaWQiOiI3Mzg1NDI0MjI2OTM5NjA5NDk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 195bc3b3c4978e4ecf2b1f5464bf36c3828111948817b73212b45fe5a2fef7e1 |
| hovercard-subject-tag | issue:3129690808 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/temporalio/samples-python/192/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7a7eafacc0f66d9ecbab69ee6a5546833ff552837db12dbd5f4db9ab474632b9/temporalio/samples-python/issues/192 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7a7eafacc0f66d9ecbab69ee6a5546833ff552837db12dbd5f4db9ab474632b9/temporalio/samples-python/issues/192 |
| og:image:alt | 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) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Natim |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/temporalio/samples-python git https://github.com/temporalio/samples-python.git |
| octolytics-dimension-user_id | 56493103 |
| octolytics-dimension-user_login | temporalio |
| octolytics-dimension-repository_id | 454557884 |
| octolytics-dimension-repository_nwo | temporalio/samples-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 454557884 |
| octolytics-dimension-repository_network_root_nwo | temporalio/samples-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ae90d426644ca15e89bacceb72e51f4e9dbf85f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width