Skip to content

ValueError: I/O operation on closed pipe #47

Open
@TheZaind

Description

@TheZaind

This is my code:

    from codeinterpreterapi import CodeInterpreterSession, File
    import os, dotenv
    import openai
    
    ###     Lade Variabeln      ###
    os.environ["OPENAI_API_KEY"] = "sk-XXXXXXXXXXX-Its my key:)YYYYYY"
    
    
    async def main():
        # context manager for auto start/stop of the session
        async with CodeInterpreterSession(openai_api_key="OPENAI_API_KEY", model="gpt-3.5-turbo") as session:
            # define the user request
            user_request = "Analyze this dataset and plot something interesting about it."
            files = [
                File.from_path("./bitcoin_csv.csv"),
            ]
    
            # generate the response
            response = await session.generate_response(
                user_request, files=files
            )
    
            # output to the user
            print("AI: ", response.content)
            for i, file in enumerate(response.files):
                with open(f'image_{i}.png', 'wb') as f:
                    f.write(file)
    
    
    if __name__ == "__main__":
        import asyncio
    
        asyncio.run(main())

but i only get this as my Traceback:

        AI:  Sorry, something went while generating your response.Please try again or restart the session.
        Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000013F2E2A7920>
        Traceback (most recent call last):
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 125, in __del__
            _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 78, in __repr__
            info.append(f'stdout={stdout.pipe}')
                        ^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 80, in __repr__
            info.append(f'fd={self._sock.fileno()}')
                              ^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\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 _ProactorBasePipeTransport.__del__ at 0x0000013F2E2D1120>
        Traceback (most recent call last):
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 116, in __del__
            _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 80, in __repr__
            info.append(f'fd={self._sock.fileno()}')
                              ^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\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 _ProactorBasePipeTransport.__del__ at 0x0000013F2E2D1120>
        Traceback (most recent call last):
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 116, in __del__
            _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 80, in __repr__
            info.append(f'fd={self._sock.fileno()}')
                              ^^^^^^^^^^^^^^^^^^^
          File "C:\Users\zaind\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_utils.py", line 102, in fileno
            raise ValueError("I/O operation on closed pipe")
        ValueError: I/O operation on closed pipe`

it worked one time but then never again. Anyone got an idea or can help?

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions