updatableProcess.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:wifimitm 作者: mvondracek 项目源码 文件源码
def __del__(self, **kwargs):
        """
        Destruct object and perform cleanup.
        If the process is still running, it is stopped and warning is generated. Process should be stopped by calling
        `self.stop()` or `self.cleanup()` or by exiting the context manager.

        Warning:
            "It is not guaranteed that __del__() methods are called for objects that still exist when
            the interpreter exits."`Data model <https://docs.python.org/3.5/reference/datamodel.html>`_

        Warning:
            Destructor of object is called even in case of unsuccessful initialization. If __init__ raised
            an exception, some attributes may be uninitialized. Therefore we need to check `self._popen_initialized`
            before calling methods inherited from popen which access attributes inherited from popen.
        """
        stop_needed = False  # process needs to be stopped
        if self._popen_initialized and self.poll() is None:
            # process is running
            stop_needed = True
            warnings.warn(
                'Process {} was not stopped correctly. Stopping it by destructor, which is not always safe!'.format(
                    type(self).__name__), ResourceWarning)
        super().__del__()
        self.cleanup(stop=stop_needed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号