Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ValueError: I/O operation on closed pipe #716

Copy link
Copy link
Open
@Fractal-0

Description

@Fractal-0
Issue body actions

Describe the bug
The code runs but at the end I get a ValueError: I/O operation on closed pipe

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000024FADDA1D00>
Traceback (most recent call last):
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\proactor_events.py", line 116, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\proactor_events.py", line 80, in __repr__
    info.append(f'fd={self._sock.fileno()}')
                      ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\windows_utils.py", line 102, in fileno
    raise ValueError("I/O operation on closed pipe")
ValueError: I/O operation on closed pipe
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000024FADDA04A0>
Traceback (most recent call last):
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\base_subprocess.py", line 125, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\base_subprocess.py", line 78, in __repr__
    info.append(f'stdout={stdout.pipe}')
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\proactor_events.py", line 80, in __repr__
    info.append(f'fd={self._sock.fileno()}')
                      ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fractal\AppData\Roaming\uv\python\cpython-3.11.11-windows-x86_64-none\Lib\asyncio\windows_utils.py", line 102, in fileno
    raise ValueError("I/O operation on closed pipe")
ValueError: I/O operation on closed pipe

To Reproduce
Use this code:

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

#from litellm import experimental_mcp_client
#import litellm

import asyncio
import json


server_params = StdioServerParameters(
    command="npx",
    args=["-y", "tavily-mcp@0.2.0"],
    env={"TAVILY_API_KEY": "<key>"}
)

async def main():
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()

            # Get tools
            #tools = await experimental_mcp_client.load_mcp_tools(session, 'openai')
            #print("MCP TOOLS: ", tools)

            #messages = [{"role": "user", "content": "What is the newest Salesforce model?"}]
            #llm_response = await litellm.acompletion(
            #    model="ollama/hf.co/DevQuasar/Salesforce.Llama-xLAM-2-8b-fc-r-GGUF:Q8_0",
            #    api_key='sk-1234',
            #    messages=messages,
            #    tools=tools,
            #)
            #print("LLM RESPONSE: ", json.dumps(llm_response, indent=4, default=str))
            pass
    
asyncio.run(main())

**Expected behavior**
No ValueError, I can't use try except blocks either in the function or on the asyncio run

**Desktop (please complete the following information):**
 - OS: Windows 11
 - Version 1.8.1
- Python 3.11 (uv venv)

**Additional context**
I have traced it back to session.initialize, if I remove that there is no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.