While using pipe server from asyncio (Windows/ProactorEventLoop) I ran
into the following exception on shutdown:
Future/Task exception was never retrieved
future: _OverlappedFuture<exception=BrokenPipeError(32, 'The pipe has
been ended', None, 109, None)>
Traceback (most recent call last):
File "c:\Python34\lib\asyncio\windows_events.py", line 428, in _poll
value = callback(transferred, key, ov)
File "c:\Python34\lib\asyncio\windows_events.py", line 304, in finish
ov.getresult()
BrokenPipeError: [WinError 109] The pipe has been ended
Tried with:
Python 3.4.0rc3 (v3.4.0rc3:8a81cdab3e9d, Mar 9 2014, 20:24:29) [MSC
v.1600 32 bit (Intel)] on win32
Attached is a minimal repro, together with a workaround.
Is this a tulip/asyncio bug?
import asyncio
loop = asyncio.ProactorEventLoop()
@asyncio.coroutine
def start_and_stop_server():
[server] = yield from loop.start_serving_pipe(None,
"\\\\.\\pipe\\DUMMY_PIPE")
# Allow the server to enter its loop.
yield from asyncio.sleep(0, loop=loop)
server.close()
loop.stop()
def run_loop_a_bit_more():
@asyncio.coroutine
def dummy():
pass
loop.run_until_complete(dummy())
asyncio.async(start_and_stop_server(), loop=loop)
loop.run_forever()
#run_loop_a_bit_more() # <-- uncomment to apply workaround
loop.close()