本文整理汇总了Python中paramiko.file.BufferedFile.close方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedFile.close方法的具体用法?Python BufferedFile.close怎么用?Python BufferedFile.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paramiko.file.BufferedFile
的用法示例。
在下文中一共展示了BufferedFile.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _close
# 需要导入模块: from paramiko.file import BufferedFile [as 别名]
# 或者: from paramiko.file.BufferedFile import close [as 别名]
def _close(self, async_=False):
# We allow double-close without signaling an error, because real
# Python file objects do. However, we must protect against actually
# sending multiple CMD_CLOSE packets, because after we close our
# handle, the same handle may be re-allocated by the server, and we
# may end up mysteriously closing some random other file. (This is
# especially important because we unconditionally call close() from
# __del__.)
if self._closed:
return
self.sftp._log(DEBUG, "close({})".format(u(hexlify(self.handle))))
if self.pipelined:
self.sftp._finish_responses(self)
BufferedFile.close(self)
try:
if async_:
# GC'd file handle could be called from an arbitrary thread
# -- don't wait for a response
self.sftp._async_request(type(None), CMD_CLOSE, self.handle)
else:
self.sftp._request(CMD_CLOSE, self.handle)
except EOFError:
# may have outlived the Transport connection
pass
except (IOError, socket.error):
# may have outlived the Transport connection
pass
示例2: close
# 需要导入模块: from paramiko.file import BufferedFile [as 别名]
# 或者: from paramiko.file.BufferedFile import close [as 别名]
def close(self):
"""
Close this channel file. The corresponging channel direction is shut down as well.
"""
BufferedFile.close(self)
if self._flags & self.FLAG_WRITE:
self.channel.shutdown_write()
if self._flags & self.FLAG_READ:
self.channel.shutdown_read()