qweeze / uring_file

Asynchronous file I/O with io_uring and asyncio
MIT License
22 stars 5 forks source link

`OSError: [Errno 9] Bad file descriptor` when trying to write file #2

Open lezwon opened 3 years ago

lezwon commented 3 years ago

Hi, I tried running this code:

import string
import asyncio
import uring_file
import os

async def main():
    path = 'test.txt'

    f = uring_file.File(path)
    await f.open(os.O_CREAT | os.O_WRONLY)
    await f.write(b'hello\nworld')
    await f.close()

if __name__ == "__main__":
    asyncio.run(main())

I get the following error:

ubuntu@pc:~$ python3 main.py 
Exception in callback Uring.eventfd_callback()
handle: <Handle Uring.eventfd_callback()>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/ubuntu/uring_file.py", line 48, in eventfd_callback
    result = liburing.trap_error(cqe.res)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/liburing/wrapper.py", line 27, in trap_error
    raise OSError(-no, strerror(-no))
OSError: [Errno 9] Bad file descriptor

These are the system details. It is an AWS machine.

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal
5.4.0-1038-aws

I installed liburing from source. Could you tell me if I'm doing something wrong?

qweeze commented 3 years ago

There's a chance that you'll need newer kernel for this. You should be able to check supported capabilities by running:

import liburing
print(liburing.probe())

If it doesn't help, try asking here - https://github.com/YoSTEALTH/Liburing