AssertionError when using ProactorEventLoop
See original GitHub issueThe ProactorEventLoop is the only event loop on Windows that supports subprocesses, but trying to use it with Discord.py results in it spitting out an error and soft locking.
Error message:
Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...op_reading()]>)
handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...op_reading()]>)>
Traceback (most recent call last):
File "c:\python36\Lib\asyncio\events.py", line 127, in _run
self._callback(*self._args)
File "c:\python36\Lib\asyncio\proactor_events.py", line 190, in _loop_reading
data = fut.result() # deliver data later in "finally" clause
asyncio.base_futures.InvalidStateError: Result is not ready.
Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...\x92\xfd\xe9'>)
handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...\x92\xfd\xe9'>)>
Traceback (most recent call last):
File "c:\python36\Lib\asyncio\events.py", line 127, in _run
self._callback(*self._args)
File "c:\python36\Lib\asyncio\proactor_events.py", line 188, in _loop_reading
self._closing)
AssertionError
Source code to repro is just the README.md example modified to use Proactor before the Discord Client is initialized.
import discord
import asyncio, sys
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!test'):
counter = 0
tmp = await client.send_message(message.channel, 'Calculating messages...')
async for log in client.logs_from(message.channel, limit=100):
if log.author == message.author:
counter += 1
await client.edit_message(tmp, 'You have {} messages.'.format(counter))
elif message.content.startswith('!sleep'):
await asyncio.sleep(5)
await client.send_message(message.channel, 'Done sleeping')
client.run('token')
I’m running Windows 7 with Python 3.6.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Issue 33833: ProactorEventLoop raises AssertionError
Sometimes when a socket transport under ProactorEventLoop is writing while the peer closes the connection, asyncio logs an AssertionError.
Read more >Asyncio event loop is closed when using asyncio.run()
This code will check if new EventLoop is ProactorEventLoop . If so, keep loop forever until proactor_wrap awaits main and schedules loop stop....
Read more >Source code for tornado.platform.asyncio
Configuring ``asyncio`` to use a selector event loop may improve performance ... ProactorEventLoop # type: ignore ): # Ignore this line for mypy...
Read more >Changelog — aiohttp 3.7.3 documentation
Use text/html content type for displaying index pages by static file handler. Fix AssertionError in static file handling (#1177). Fix access log formats...
Read more >Asyncio event loop is closed when using asyncio.run()
ProactorEventLoop ) # No ProactorEventLoop is in asyncio on other OS, will raise AttributeError in that case. except (AssertionError, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For posterity, this was a Python bug that was fixed in Python 3.7 and 3.6.6.
I can repro this with py 3.6 on w10. The error however looks to be in a pretty core area, this looks like a bug in ProactorEventLoop to me