Comments (5)
@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.
@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.
@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.
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.
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)
- how to create dir and file usign async api? HOT 2
- Can't install on Amazon Linux HOT 2
- Function not implemented HOT 1
- async_open does not create file if file does not exist in mode 'a+' HOT 1
- Add support for StringIO and BytesIO HOT 1
- Can I use aiofile.async_open without a with statement? HOT 4
- Race condition in `AIOFile.open()` HOT 4
- Some sort of changelog / release notes?
- Manual context management example on readme has a bug HOT 1
- How to work with NFS? HOT 1
- Tag the source HOT 1
- AIOFile context manager looses data HOT 3
- aiofile LineReader does a read for every line in spite of having multiple lines in CHUNK_SIZE HOT 2
- Which of the methods are coroutine-safe? HOT 2
- Why is fsync calling fdsync HOT 2
- No flush API and no way to set unbuffered writes in binary mode HOT 3
- Add performance benchmarks to the readme HOT 3
- Unable to call close() twice
- Memory leak during import
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiofile.