-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
31 lines (19 loc) · 1.14 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This is txfileio, an effort to make portable asynchronous file I/O possible. It is probably
very buggy, it's definitely slow.
It uses threads and a fixed number of pre-spawned runners to do actual file I/O.
Usage is as follows:
# Somewhere in your initialization code
from twisted.internet import reactor
from txfileio.threaded import FileIOManager
filemanager = FileIOManager(reactor, maxrunners=<desired number, default 5>, queue_timeout=<timeout in seconds, default=1>)
# Then somewhere during the run:
d = filemanager.open(<the same arguments as for regular open>).addCallback(do_read)...
# A Deferred is returned, resulting in a FileIOProxy object.
FileIOProxy objects delegate all operations to the manager, and return deferreds which,
if successful, fire with results of those operations, and fail with appropriate failures.
The usage of these proxies are the same as regular files, except that they always return
Deferreds. The arguments are accepted as in a regular file-like objects.
Note also, that any additional methods your objects might have, will work too.
TODO
1. Unit tests FTW
2. Error handling is probably broken, need to look deeper