Skip to content

The presence.close() Method raises ValueError: I/O operation on closed pipe on Windows 11 #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BUZZARDGTA opened this issue Jan 25, 2025 · 4 comments

Comments

@BUZZARDGTA
Copy link

Error:

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000269DE65B600>
Traceback (most recent call last):
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python313\Lib\asyncio\proactor_events.py", line 116, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python313\Lib\asyncio\proactor_events.py", line 80, in __repr__
    info.append(f'fd={self._sock.fileno()}')
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python313\Lib\asyncio\windows_utils.py", line 102, in fileno
    raise ValueError("I/O operation on closed pipe")
ValueError: I/O operation on closed pipe

Am I the only one, am I doing something wrong ??

@BUZZARDGTA BUZZARDGTA changed the title The presence.close() Method raises ValueError: I/O operation on closed pipe on Windows The presence.close() Method raises ValueError: I/O operation on closed pipe on Windows 11 Jan 25, 2025
@BUZZARDGTA
Copy link
Author

BUZZARDGTA commented Jan 25, 2025

Script used:

from pypresence import Presence
import time


def main():
    # Replace with your application's client ID (found in Discord Developer Portal)
    CLIENT_ID = "your_client_id"

    print("Creating the Discord Presence object...")
    RPC = Presence(CLIENT_ID)

    print("Connecting to Discord...")
    RPC.connect()

    # Simulate Work
    time.sleep(1)

    # Update the rich presence
    RPC.update(
        state="Coding in Python",
        details="Using pypresence for Discord RPC"
    )
    print("Rich Presence updated.")
    print("Waiting 3 seconds...")

    # Simulate Work
    time.sleep(3)

    print("Closing connection.")
    RPC.clear()  # Clear the presence
    RPC.close()  # Properly close the connection
    print("Disconnected from Discord.")


if __name__ == "__main__":
    main()

@BUZZARDGTA
Copy link
Author

BUZZARDGTA commented Jan 25, 2025

running on:
Microsoft Windows [version 10.0.22631.4751]
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)] on win32
pypresence 4.3.0

@BUZZARDGTA
Copy link
Author

I found the issue, it puts this error when wrapping the code inside if __name__ == "__main__":

@BUZZARDGTA
Copy link
Author

BUZZARDGTA commented Jan 25, 2025

Another interesting note, when wrapping the RPC code in a class, if the Presence() object is outside of the __init__() method, then this problem also happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant