I have a directory in which there are about 5 more directories. Each of these directories contains a huge number of files. I need to check the file descriptor of each file, and then take the necessary actions, such as deleting a file.
It happens on a working server and the processor is very heavily loaded when I do it in an oak way, like this:
[self.handle_file(path) for path in glob.iglob(PATH + '/*/*')] How can this be done more optimally?
os.scandir()can help. Here are some examples of usage . - jfs