coc.py
coc.py copied to clipboard
"RuntimeError: Event loop is closed" when using the warlog example
I am using the example on this page, which mostly works other than the errors it spits out at the end. See below:
...
League War Season - No opponent info available
League War Season - No opponent info available
League War Season - No opponent info available
League War Season - No opponent info available
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001C73B34A1F0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001C73B34A1F0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001C73B34A1F0>
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
The only part of the script that has been modified is the username, password, and clan search string. What does that error mean and why is it happening? I've tried other examples as well and had similar issues.
Honestly, this python library seems to be overly complex. I don't understand why there are so many asynchronous functions either. I appreciate that it exists, but it's difficult to use.
+1 same issue here
Honestly, this python library seems to be overly complex. I don't understand why there are so many asynchronous functions either. I appreciate that it exists, but it's difficult to use.
Actually this library is async because async makes code non blockable which means smooth running of script,and if you are finding any difficulty in using this library feel free to join our discord community https://discord.gg/clashapi
According to this aiohttp issue, this aiohttp issue and this httpx issue the problem is the underlaying SSL transport. Currently the only way to avoid this error message is to give the SSL transport time to shutdown by adding a time.sleep(0.25)
or await asyncio.sleep(0.25)
in coc.http.HTTPClient.close(). With that, no exception gets raised executing the sample code.
we agreed that this isn't our job to fix, so I will close this.