Cog-Creators / Cog-Creators/Red-DiscordBot
[Audio/Lavalink] ValueError: I/O operation on closed pipe when shutdown/restart while using default Java executable (solution inside)
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 2.5k
- Avg merge
- 6d 16h
- Merged PRs (30d)
- 1
Description
### What Red version are you using?
3.5.16
### What were you trying to do?
Shutdown the bot to update from 3.5.15 to 3.5.16
### What did you expect to happen?
Shutdown peacefully and then restart the bot and Lavalink
### What actually happened?
It occurred to me that one of my RedBot instances was raising error at asyncio:
```Exception ignored in:
Traceback (most recent call last):
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 126, in __del__
self.close()
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 104, in close
proto.pipe.close()
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 758, in call_soon
self._check_closed()
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in:
Traceback (most recent call last):
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 115, in __del__
_warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 79, in __repr__
info.append(f'fd={self._sock.fileno()}')
^^^^^^^^^^^^^^^^^^^
File "C:\Users\*****\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
```
which failed to terminate java.exe and blocked the port, making it impossible to restart Lavalink.
### How can we reproduce this error?
1. `!llset java` to set to the default java executable. The default executable for me was `C:\Program Files\Common Files\Oracle\Java\javapath\java.EXE`
2. `!shutdown` or `!restart`
3. ValueError will occur
### Anything else?
Temporary solution: Change your Java executable to Java 11.
This error did not happen on the instance that uses a different Java executable (jdk-11.0.16). No error occurred when shutting down/restarting while using this version of java.exe. I lost an hour and a half because I thought the problem was the port or the Lavalink.exe.
Contributor guide
Assessment
This issue has not been assessed yet.