selector.cleanup

This module is for cleaning up temporary files.

Classes

TempFileCleaner(logger[, temp_dir, age_limit])

Cleaning up old, unused temp files.

class selector.cleanup.TempFileCleaner(logger, temp_dir=None, age_limit=600)[source]

Bases: object

Cleaning up old, unused temp files.

Note

Only in use if scenario.cleanup is True.

Parameters:
  • logger (logging.Logger) – Initialized logging object.

  • temp_dir (str) – Path to the temporary directory.

  • age_limit (int) – Number of seconds a file can exist unused before removal.

clean_up()[source]

Clean up unused and inactive files.

file_in_use(file_path)[source]

Check if the file is locked or in use.

Parameters:

file_path (str) – Path to the file to look after.

Returns:

Whether the file is in use.

Return type:

bool

list_open_files()[source]

Get list of open files for the current process.

Returns:

List of the open temporary files.

Return type:

list

track_file(file_path)[source]

Adds a file to the list.

Parameters:

file_path (str) – Path to the file to look after.