aiofile icon indicating copy to clipboard operation
aiofile copied to clipboard

aiofile 3.1.1 pipe example not working under Debian stable

Open Steve-Newcomb opened this issue 5 years ago • 1 comments

I'm running the aiofile 3.1.1 pipe example under Linux (Debian stable, python 3.7). It usually stops with no other output than this:

201021 14:17 ~ srn@lije{1}% python3 /tmp/z.py Start reader Start reader Start writer C-c C-cExited Traceback (most recent call last): File "/tmp/z.py", line 46, in loop.run_until_complete(main()) File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete self.run_forever() File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever self._run_once() File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once handle._run() File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.7/dist-packages/caio/asyncio_base.py", line 55, in _run step(operation, future) File "/usr/local/lib/python3.7/dist-packages/caio/asyncio_base.py", line 43, in step self.context.submit(*operations.keys()) KeyboardInterrupt 201021 14:18 ~ srn@lije{1}%

(Since nothing is output, I give up and press control-C.)

I have made this test several times, trying to use pdb and with other minor changes, and one of the tests yielded a few loop.time() outputs, like this:

Start reader Start reader Start writer 1131834.8124811131834.8126551131834.812847 1131834.813134 C-c C-c C-c C-cTraceback (most recent call last): File "/usr/local/ch-tools3/z.py", line 64, in loop.run_until_complete(main()) File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete self.run_forever() File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever self._run_once() File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once handle._run() File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.7/dist-packages/caio-0.6.3-py3.7-linux-x86_64.egg/caio/asyncio_base.py", line 55, in _run step(operation, future) File "/usr/local/lib/python3.7/dist-packages/caio-0.6.3-py3.7-linux-x86_64.egg/caio/asyncio_base.py", line 43, in step self.context.submit(*operations.keys())

Here's /tmp/z.py, which I believe is a verbatim copy of the example from the README:

import os import asyncio from aiofile import AIOFile, Reader, Writer

async def reader(fname): print('Start reader') async with AIOFile(fname, 'r') as afp: while True: # Maximum expected chunk size, must be passed. # Otherwise will be read zero bytes # (because unix pipe has zero size) data = await afp.read(4096) print(data)

async def writer(fname): print('Start writer') async with AIOFile(fname, 'w') as afp: while True: await asyncio.sleep(1) await afp.write('%06f' % loop.time())

async def main(): fifo_name = "/tmp/test.fifo"

if os.path.exists(fifo_name):
    os.remove(fifo_name)

os.mkfifo(fifo_name)

# Starting two readers and one writer, but only one reader
# will be reading at the same time.
await asyncio.gather(
    reader(fifo_name),
    reader(fifo_name),
    writer(fifo_name),
)

loop = asyncio.new_event_loop() asyncio.set_event_loop(loop)

try: loop.run_until_complete(main()) finally: # Shutting down and closing file descriptors after interrupt loop.run_until_complete(loop.shutdown_asyncgens()) loop.close() print('Exited')


201021 14:18 ~ srn@lije{1}% uname -a Linux lije 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux

Steve-Newcomb avatar Oct 22 '20 17:10 Steve-Newcomb

Please see troubleshooting section in caio

mosquito avatar Sep 27 '21 13:09 mosquito