cf.OF_FRACTION

cf.OF_FRACTION(*arg)[source]

The amount of concurrently open files above which files containing data arrays may be automatically closed.

The amount is expressed as a fraction of the maximum possible number of concurrently open files.

Note that closed files will be automatically reopened if subsequently needed by a variable to access its data array.

Parameters:
arg: float, optional

The new fraction (between 0.0 and 1.0). The default is to not change the current behaviour.

Returns:
out: float

The value prior to the change, or the current value if no new value was specified.

Examples:
>>> cf.OF_FRACTION()
0.5
>>> old = cf.OF_FRACTION(0.33)
>>> cf.OF_FRACTION(old)
0.33
>>> cf.OF_FRACTION()
0.5

The fraction may be translated to an actual number of files as follows:

>>> old = cf.OF_FRACTION(0.75)
>>> import resource
>>> max_open_files = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
>>> threshold = int(max_open_files * cf.OF_FRACTION())
>>> max_open_files, threshold
(1024, 768)