mosquito/aiofile

SystemError: (22, 'Invalid argument') occurs when reading/writing on Raspberry PI OS

peter-vanpoucke opened this issue · 4 comments

I get the following error when running the async_open example.

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/caio/asyncio_base.py", line 43, in step
    self.context.submit(*operations.keys())
SystemError: (22, 'Invalid argument')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "async_open_test.py", line 18, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "async_open_test.py", line 7, in main
    await afp.write("Hello ")
  File "/home/pi/.local/lib/python3.7/site-packages/aiofile/utils.py", line 284, in write
    await operation
  File "/home/pi/.local/lib/python3.7/site-packages/aiofile/aio.py", line 243, in write_bytes
    data[written:], self.fileno(), offset + written,
  File "/home/pi/.local/lib/python3.7/site-packages/caio/asyncio_base.py", line 87, in submit
    await future
  File "/home/pi/.local/lib/python3.7/site-packages/caio/asyncio_base.py", line 48, in step
    self.context.submit(operation)
SystemError: (22, 'Invalid argument')

Versions:

  • aiofile==3.3.3
  • caio==0.6.3
  • Python 3.7.3
  • libaio1 0.3.112-3 (wasn't installed initially)
  • Linux raspberrypi 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux

Am I missing something?

Natim commented

Duplicate of #42 (comment)

The issue doesn't occur when I run arm64 on the Pi. (so: Linux 5.4.79-v8+ #1373 SMP PREEMPT Mon Nov 23 13:32:41 GMT 2020 aarch64 GNU/Linux)

Not sure if this info should be added to #42?

I got it working by adding this:

import platform
uname = platform.uname()
if uname.machine == 'armv7l':
    import caio

    second = caio.variants[1]
    second_asyncio = caio.variants_asyncio[1]

    caio.Context = second.Context      # type: ignore
    caio.Operation = second.Operation  # type: ignore
    caio.AsyncioContext = second_asyncio.AsyncioContext   # type: ignore

It's using thread_aio now. Hope caio will get supported, but until then it's working.

I guess this is also a duplicate of: mosquito/caio#6.