You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting RuntimeErrors every time I try to run async io sample code because the event loop is closed. The only way I've found to fix this on my machine is by changing the default event loop policy to the selector policy:
I'll add that I have 2 environments I typically test in:
(env 1) Windows / VS Code / bash / Python 3.9.5 in a virtual environment
(env 2) Ubuntu / WSL / bash / Python 3.8.10 in a virtual environment
The Cosmos code sample works in Windows environment (env 1) but returns "RuntimeError: Event loop is closed". The same code doesn't throw the error in Ubuntu (env 2). Is this related to encode/httpx#914? I noticed using code similar to the snippet below for service bus or event hubs works in both environments with no error.
Sample code to return event loop error.
import os
import asyncio
from azure.cosmos.aio import CosmosClient
ENDPOINT = os.environ["COSMOS_ENDPOINT"]
KEY = os.environ["COSMOS_KEY"]
async def manage_cosmos():
async with CosmosClient(url=ENDPOINT, credential=KEY) as client:
print("Client created")
# Some code here
asyncio.run(manage_cosmos())
Hi @gahl-levy, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.
-Windows 11
-Python 3.9.1
I'm getting RuntimeErrors every time I try to run async io sample code because the event loop is closed. The only way I've found to fix this on my machine is by changing the default event loop policy to the selector policy:
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
To Reproduce
Run this sample code with your db account:
Get this error (it seems like the operation still completes regardless):
The text was updated successfully, but these errors were encountered: