Package twisted :: Package persisted :: Module filepile
[show private | hide private]
[frames | no frames]

Module twisted.persisted.filepile

Consecutive filesystem mashing. See FilePile.__doc__ for details.
Classes
FilePile  
FilePileIterator I am a sorted list of files stored in a tree of directories.
LenientIntCompare I am a comparator object which can be used for directories which has had objects created in it by nextFileName.
_b Backwards iterator for FilePile.
_FilePileStackEntry I represent a cursor in an open directory; nothing to see here, move along, move along.

Function Summary
  nextFileName(dirname, ext, directory)
Get a sequential file-name from a directory in a NFS and SMP-safe way.
  unique()
  _bisect_cmp(a, x, cmpfunc, lo, hi)
A left-bisect on a vector using a user-provided comparison function.
  _lenieint(x)
Try to convert an object to an int, but if we can't, just give up and return the object itself.

Variable Summary
str prochost
int procpid

Function Details

nextFileName(dirname, ext, directory=0)

Get a sequential file-name from a directory in a NFS and SMP-safe way.

When you use this filename, do not run file() or symlink() on it; you must create a file elsewhere (you can use a mutated version of the returned filename to achieve SMP/NFS safety) and use os.rename over the returned filename.

The returned filename includes the passed-in dirname; if you want an absolute path, pass an absolute dirname - don't manipulate the returned path.

This will allocate a file-name using the following strategy:
  • look for a symlink named ext.sequence
  • if it's found
    • read the body of this symlink and jump to that sequence number
  • otherwise
    • start from 0
  • keep incrementing the sequence number until you arrive at a [sequence].ext which does not exist. (this is verified by creating a symlink, which is should always be an atomic test-and-set for non-local filesystems.)

This algorithm is optimistic and may block for a while if there are a lot of concurrent processes working on the same directory. Also, if you delete a symlink created in this way, sequence numbers may repeat.

The optional 'directory' parameter will create a directory rather than a symlink, which is also safe. As it is an empty directory, it will support os.rename'ing another directory over it. At least on Linux. At least on version 2.4. 10+. Maybe.

_bisect_cmp(a, x, cmpfunc=<built-in function cmp>, lo=0, hi=None)

A left-bisect on a vector using a user-provided comparison function.

_lenieint(x)

Try to convert an object to an int, but if we can't, just give up and return the object itself.

Variable Details

prochost

Type:
str
Value:
'pyramid.twistedmatrix.com'                                            

procpid

Type:
int
Value:
18658                                                                  

Generated by Epydoc 1.1 on Fri Jun 27 03:48:23 2003 http://epydoc.sf.net