Git Product home page Git Product logo

Comments (5)

mosquito avatar mosquito commented on May 26, 2024

@ilookhandsometoday in the normal case, the operating system seek to the beginning or end of the file, however, when using the asynchronous API, there is no guarantee that the file has not changed in another coroutine and has not grown. Don't rely on size either.

This library mimics the usual synchronous API, and offset is a virtual, just a number in the class instance.

from aiofile.

dimaqq avatar dimaqq commented on May 26, 2024

@ilookhandsometoday in the normal case, the operating system seek to the beginning or end of the file, however, when using the asynchronous API, there is no guarantee that the file has not changed in another coroutine and has not grown. Don't rely on size either.

This library mimics the usual synchronous API, and offset is a virtual, just a number in the class instance.

The synchronous Python API has the same problem when the file object is used in several threads.

UNIX has a smaller problem (file size being changed) when file descriptor is duplicated via dup(2) of the process is cloned via fork/vfork/clone, or when some other process changes the file.

Somehow, both Python API and UNIX API are used with quite a bit of success.

I'd argue that what @ilookhandsometoday wants, is ultimately for this library to issue lseek(2) on the underlying file descriptor.

from aiofile.

mosquito avatar mosquito commented on May 26, 2024

@dimaqq the point here is that this will be an emulation, no really guarantee of compatibility, and how is this different from just reading the entire remaining file by looking the size?

from aiofile.

dimaqq avatar dimaqq commented on May 26, 2024

The requested operation takes place at the absolute
position in the file as given by aio_offset, as if lseek() were
called immediately prior to the operation with an offset equal to
aio_offset and a whence equal to SEEK_SET.

https://man7.org/linux/man-pages/man3/aio_read.3p.html

This is a limitation of the operating system API.
(I've only checked Linux, other OS may vary.)

I'm proposing to close the issue as "impossible today".

from aiofile.

ilookhandsometoday avatar ilookhandsometoday commented on May 26, 2024

To be honest with you all, at this point I don't even remember why I've opened this issue. I did get some useful info on the intricacies of working with files, I guess, so it was not all in vain. Thank you for your time!

from aiofile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.