Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIOfile 3.0.0. raises (22, 'Invalid argument') if used on Ubuntu 18.4 #42

Closed
slieberth opened this issue Jul 23, 2020 · 7 comments
Closed
Assignees

Comments

@slieberth
Copy link

AIOfile 1.5.1 worked fine with Ubuntu18.04, but AIOfile 3.0.0 raises an issue (22, 'Invalid argument') on Ubuntu18.04
AIOfile 3.0.0 works fine on Ubuntu20.04

test script:

root@ubuntu-s-1vcpu-1gb-fra1-01:~# cat aiofile_test.py 
import asyncio
from aiofile import AIOFile


async def main():
    async with AIOFile("/tmp/hello.txt", 'w+') as afp:
        await afp.write("Hello ")
        await afp.write("world", offset=7)
        await afp.fsync()

        print(await afp.read())


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

output:

root@ubuntu-s-1vcpu-1gb-fra1-01:~# pip3 install aiofile==3.0.0
Collecting aiofile==3.0.0
  Using cached https://files.pythonhosted.org/packages/f9/e5/a3215b7da4fb90c3abb7850ae1f3fa4c7553ab33381c7f49aaccc8adc531/aiofile-3.0.0-py3-none-any.whl
Requirement already satisfied: caio~=0.5.3 in /usr/local/lib/python3.6/dist-packages (from aiofile==3.0.0)
Installing collected packages: aiofile
  Found existing installation: aiofile 1.5.1
    Uninstalling aiofile-1.5.1:
      Successfully uninstalled aiofile-1.5.1
Successfully installed aiofile-3.0.0

root@ubuntu-s-1vcpu-1gb-fra1-01:~# python3 aiofile_test.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-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 "aiofile_test.py", line 15, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "aiofile_test.py", line 11, in main
    print(await afp.read())
  File "/usr/local/lib/python3.6/dist-packages/aiofile/aio.py", line 163, in close
    await self.fsync()
  File "/usr/local/lib/python3.6/dist-packages/aiofile/aio.py", line 223, in fsync
    return await self.__context.fdsync(self.fileno())
  File "/usr/local/lib/python3.6/dist-packages/caio/asyncio_base.py", line 87, in submit
    await future
  File "/usr/local/lib/python3.6/dist-packages/caio/asyncio_base.py", line 48, in step
    self.context.submit(operation)
SystemError: (22, 'Invalid argument')

works fine with ubuntu20.04

regards Stefan

@mosquito
Copy link
Owner

So strange, cause all tests running on the ubuntu 18.04 based image. I guess it's not an ubuntu version problem, could you please provide detailed environment information?

@mosquito
Copy link
Owner

mosquito commented Jul 24, 2020

Might be rewrite your test using caio directly and rerun it on you environment will be more clear and helps determine the problem.

@Olegt0rr
Copy link

Olegt0rr commented Aug 13, 2020

The same problem
Windows - OK
Debian 9 - SystemError: (22, 'Invalid argument')
Debian 10 - OK

@mosquito
Copy link
Owner

Please provide the kernel versions

@suupaafly
Copy link

The problem is repeated on
Python 3.8.2
CentOS Linux release 7.8.2003
Kernel - 3.10.0-957.12.2.el7.x86_64

@mosquito
Copy link
Owner

mosquito commented Aug 26, 2020

Fixed in caio==0.6.0. Linux before 4.14 never will work correctly I guess in this case. The caio==0.6.0 checks the kernel version and use another implementation as a fallback. Not ideal but works out of the box.

UPD: OMG. After some tests, I found out the correct versions.

So FSYNC and FDSYNC start working since 4.18 (prints RunitmeWarning added after module import)

@mosquito
Copy link
Owner

mosquito commented Mar 2, 2021

After the following issues I restrict linux_aio modile loading with kernel before 4.18. So the thread based implementation will be works in this case.

@mosquito mosquito closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants