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

nest_asyncio hangs AsyncAnthropic #602

Open
sang-d opened this issue Jul 17, 2024 · 4 comments
Open

nest_asyncio hangs AsyncAnthropic #602

sang-d opened this issue Jul 17, 2024 · 4 comments

Comments

@sang-d
Copy link

sang-d commented Jul 17, 2024

When running with nest_asyncio.apply() the AsyncAnthropic execution keeps staying in the thread

import anthropic
import asyncio
import nest_asyncio

nest_asyncio.apply()

client = anthropic.AsyncAnthropic()

message = asyncio.run(
   client.messages.create(
       model="claude-3-5-sonnet-20240620",
       max_tokens=1000,
       temperature=0,
       system="You are a world-class poet. Respond only with short poems.",
       messages=[
           {
               "role": "user",
               "content": "Why is the ocean salty and the sun is so bright?",
           }
       ],
   )
)
print(message.content[0].text)

@RobertCraigie
Copy link
Collaborator

RobertCraigie commented Sep 9, 2024

Could you share any more details on what your use case is with nest_asyncio? It appears to be archived.

For what it's worth, we're not doing anything fancy with async on top of httpx / anyio so I suspect this issue would need to be resolved there first.

@joelpob
Copy link

joelpob commented Sep 10, 2024

Also running nest_asyncio.apply(), just updated from 0.28 to 0.34.1 and have hit this problem also.

@RobertCraigie
Copy link
Collaborator

@joelpob would you be able to verify if nest_asyncio works with httpx? I suspect this issue lies within the http library we're using / one of it's transitive dependencies

@omarhurani
Copy link

omarhurani commented Oct 13, 2024

It appears to be archived.

The repo is archived because its owned passed away.

I am facing the same issue, and I am unable to reproduce it using HTTPX on its own

Edit: The issue is nest_asyncio with anyio, specifically run_sync_in_worker_thread. I think this issue might be related: agronholm/anyio#418

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

4 participants