Skip to content

Racing with another loop to spawn a process. #985

Open
@LordDangerous

Description

@LordDangerous

Hello,
I'm using fastapi with uvicorn that has as loop type uvloop inside a langgraph agent.

Inside, I'm using search_graph.run() (also tested run_safe_async()) but then i get this Racing with another loop error.

Traceback (most recent call last):
2025-06-13 10:57:11 File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 279, in run
2025-06-13 10:57:11 await self._transport.connect()
2025-06-13 10:57:11 File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_transport.py", line 133, in connect
2025-06-13 10:57:11 raise exc
2025-06-13 10:57:11 File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_transport.py", line 120, in connect
2025-06-13 10:57:11 self._proc = await asyncio.create_subprocess_exec(
2025-06-13 10:57:11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-06-13 10:57:11 File "/usr/local/lib/python3.11/asyncio/subprocess.py", line 223, in create_subprocess_exec
2025-06-13 10:57:11 transport, protocol = await loop.subprocess_exec(
2025-06-13 10:57:11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-06-13 10:57:11 File "uvloop/loop.pyx", line 2841, in subprocess_exec
2025-06-13 10:57:11 File "uvloop/loop.pyx", line 2799, in __subprocess_run
2025-06-13 10:57:11 File "uvloop/handles/process.pyx", line 611, in uvloop.loop.UVProcessTransport.new
2025-06-13 10:57:11 File "uvloop/handles/process.pyx", line 76, in uvloop.loop.UVProcess._init
2025-06-13 10:57:11 RuntimeError: Racing with another loop to spawn a process.

My implementation inside the function is very simple:
search_graph = SearchGraph(
prompt=ref,
config=self.graph_config,
schema=Product
)
result = search_graph.run()

Im using Docker
Important requirements:
uvicorn==0.34.3
scrapegraphai==1.55.0
playwright==1.52.0
langgraph==0.4.8
langserve==0.3.1

My command docker-compose command:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-config=log_conf.yaml --reload
(when --loop is not defined it uses uvloop in my case)

I'm guessing that this can be related to conflicts between uvloop and asyncio from playwright?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    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