Skip to content

pydantic_graph: asyncio.get_event_loop() is deprecated since python 3.12 #1196

Open
@JohnUiterwyk

Description

@JohnUiterwyk

Initial Checks

  • I confirm that I'm using the latest version of Pydantic AI

Description

asyncio.get_event_loop() has been deprecated since version 3.12

The following code at line 15 in pydantic_graph/_utils.py emits a deprecation warning
event_loop = asyncio.get_event_loop()

Python docs recommend using asyncio.get_running_loop() instead.
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop

Example Code

from pydantic_ai import Agent
from pydantic_ai.models.test import TestModel
agent = Agent(TestModel())
agent.run_sync('hi')"


  /home/user/.local/lib/python3.13/site-packages/pydantic_graph/_utils.py:15: DeprecationWarning: There is no current event loop
    event_loop = asyncio.get_event_loop()

Python, Pydantic AI & LLM client version

python=3.13
pydantic=2.10.6
pydantic-ai-slim=0.0.42

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions