Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`tcp`.`_IFileDescriptorReservation``

interface documentation

`class _IFileDescriptorReservation(Interface): (source)`

Known implementations: `twisted.internet.tcp._FileDescriptorReservation`, `twisted.internet.tcp._NullFileDescriptorReservation`

View In Hierarchy

An open file that represents an emergency reservation in the process' file descriptor table. If `Port` encounters `EMFILE` on `accept(2)`, it can close this file descriptor, retry the `accept` so that the incoming connection occupies this file descriptor's space, and then close that connection and reopen this one.

Calling `_IFileDescriptorReservation.reserve` attempts to open the reserve file descriptor if it is not already open. `_IFileDescriptorReservation.available` returns `True` if the underlying file is open and its descriptor claimed.

`_IFileDescriptorReservation` instances are context managers; entering them releases the underlying file descriptor, while exiting them attempts to reacquire it. The block can take advantage of the free slot in the process' file descriptor table accept and close a client connection.

Because another thread might open a file descriptor between the time the context manager is entered and the time `accept` is called, opening the reserve descriptor is best-effort only.

Method | `__enter__` | Release the underlying file descriptor so that code within the context manager can open a new file.
Method | `__exit__` | Attempt to re-open the reserved file descriptor. See `reserve` for caveats.
Method | `available` | Is the reservation available?
Method | `reserve` | Attempt to open the reserved file descriptor; if this fails because of `EMFILE`, internal state is reset so that another reservation attempt can be made.

def __enter__(): (source)

Release the underlying file descriptor so that code within the context manager can open a new file.

def __exit__(excType, excValue, traceback): (source)

Attempt to re-open the reserved file descriptor. See `reserve` for caveats.

Parameters
excType | See `object.__exit__`
excValue | See `object.__exit__`
traceback | See `object.__exit__`

def available(): (source)

Is the reservation available?

Returns
`True` if the reserved file descriptor is open and can thus be closed to allow a new file to be opened in its place; `False` if it is not open.

def reserve(): (source)

Attempt to open the reserved file descriptor; if this fails because of `EMFILE`, internal state is reset so that another reservation attempt can be made.

Raises
`Exception` | Any exception except an `OSError` whose errno is `EMFILE`.