Skip to content

Async file

A file-like object for reading and writing data.

Created by the open method of the AsyncOperator class.

closed async property #

Check if the file is closed.

__aenter__() #

Enter the runtime context related to this object.

__aexit__(exc_type, exc_value, traceback) #

Exit the runtime context related to this object.

close() async #

Close the file.

read(size=None) async #

Read the content of the file.

Parameters:

Name Type Description Default
size int

The number of bytes to read. If None, read all.

None

Returns:

Type Description
bytes

The content of the file as bytes.

readable() async #

Check if the file is readable.

seek(pos, whence=0) async #

Set the file's current position.

Parameters:

Name Type Description Default
pos int

The position to set.

required
whence int

The reference point for the position. Can be 0, 1, or 2.

0

Returns:

Type Description
int

The new position in the file.

seekable() async #

Check if the file supports seeking.

tell() async #

Get the current position in the file.

Returns:

Type Description
int

The current position in the file.

writable() async #

Check if the file is writable.

write(bs) async #

Write the content to the file.

Parameters:

Name Type Description Default
bs bytes

The content to write.

required