使用Python Inotifyx,如果需要在程序退出之前,我是否必须删除手表并关闭打开的系统文件描述符?例如,如果我每次运行都创建一个(文件描述符 +手表),并且不关闭它,是否会有一些问题?

有帮助吗?

解决方案

内核商店将手表视为完整的路径,因此最好关闭手表,它也可以从VFS上进行不必要的工作。至于文件描述符,这将取决于您打开了多少其他。

有点像一个电话,很高兴告诉另一方您已经停止聆听,挂断电话是可选的,但常规。如果您需要某种东西,请保留它。

其他提示

It's always a good idea to release resources (e.g. free memory, close file descriptors, waitpid(2) on child processes, etc) whenever you're done using them. Being lazy and letting the operating system take care of it for you when you exit is a sure way to cause bugs in the future.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top