def aclose(self):
"""Like :meth:`io.IOBase.close`, but async.
This is also shielded from cancellation; if a cancellation scope is
cancelled, the wrapped file object will still be safely closed.
"""
# ensure the underling file is closed during cancellation
with _core.open_cancel_scope(shield=True):
await trio.run_sync_in_worker_thread(self._wrapped.close)
await _core.checkpoint_if_cancelled()
评论列表
文章目录