Skip to content
/ txfileio Public

A try at asynchronous file I/O in twisted. Maybe it will work.

License

Notifications You must be signed in to change notification settings

jafd/txfileio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A try at asynchronous file I/O in twisted. Maybe it will work.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages