# ``twisted`.`internet`.`process`.`_FDDetector``

class documentation

`class _FDDetector: (source)`

View In Hierarchy

This class contains the logic necessary to decide which of the available system techniques should be used to detect the open file descriptors for the current process. The chosen technique gets monkey-patched into the _listOpenFDs method of this class so that the detection only needs to occur once.

Method | `__init__` | Undocumented
Instance Variable | `getpid` | The implementation of getpid to use, returns the PID of the running process.
Instance Variable | `listdir` | The implementation of listdir to use. This gets overwritten by the test cases.
Instance Variable | `openfile` | The implementation of open() to use, by default the Python builtin.
Method | `_devFDImplementation` | Simple implementation for systems where /dev/fd actually works. See: http://www.freebsd.org/cgi/man.cgi?fdescfs
Method | `_fallbackFDImplementation` | Fallback implementation where either the resource module can inform us about the upper bound of how many FDs to expect, or where we just guess a constant maximum if there is no resource module.
Method | `_getImplementation` | Pick a method which gives correct results for `_listOpenFDs` in this runtime environment.
Method | `_listOpenFDs` | Return an iterable of file descriptors which may be open in this process.
Method | `_procFDImplementation` | Simple implementation for systems where /proc/pid/fd exists (we assume it works).
Instance Variable | `_implementations` | Undocumented

def __init__(self): (source)

Undocumented

getpid = (source)
The implementation of getpid to use, returns the PID of the running process.
listdir = (source)
The implementation of listdir to use. This gets overwritten by the test cases.
openfile = (source)
The implementation of open() to use, by default the Python builtin.
def _devFDImplementation(self): (source)
Simple implementation for systems where /dev/fd actually works. See: http://www.freebsd.org/cgi/man.cgi?fdescfs
def _fallbackFDImplementation(self): (source)

Fallback implementation where either the resource module can inform us about the upper bound of how many FDs to expect, or where we just guess a constant maximum if there is no resource module.

All possible file descriptors from 0 to that upper bound are returned with no attempt to exclude invalid file descriptor values.

def _getImplementation(self): (source)

Pick a method which gives correct results for `_listOpenFDs` in this runtime environment.

This involves a lot of very platform-specific checks, some of which may be relatively expensive. Therefore the returned method should be saved and re-used, rather than always calling this method to determine what it is.

See the implementation for the details of how a method is selected.

def _listOpenFDs(self): (source)

Return an iterable of file descriptors which may be open in this process.

This will try to return the fewest possible descriptors without missing any.

def _procFDImplementation(self): (source)
Simple implementation for systems where /proc/pid/fd exists (we assume it works).
_implementations = (source)

Undocumented