filesystem_ipc.py 文件源码

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

项目:py-aspio 作者: hexhex 项目源码 文件源码
def __init__(self) -> None:
        '''Create a temporary file.

        The path to the file can be retrieved from the `name` attribute on the returned object.

        To ensure proper removal of the file after use,
        make sure to call `cleanup()` on the returned object, or use it as a context manager.
        '''
        fd, self.name = tempfile.mkstemp(prefix='pyaspio_')
        # Ideally, we would use this file descriptor instead of reopening the file from the path later,
        # but then we do not know whether the file descriptor has already been closed.
        # (possible problems: we might leak a file descriptor, or close it twice (thus risking to close another unrelated file))
        os.close(fd)

        self._cleanup_warning = weakref.finalize(self, _warn_cleanup, type(self).__name__, self.name)  # type: ignore
        self._cleanup_warning.atexit = True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号