Использование +
модели может одновременно поддерживать чтение и запись
import base64
import select
os.system("mkfifo audio1.fifo")
with open("audio1.fifo", "wb") as fifo:
select.select([fifo],[],[fifo])
with open("out1.wav","rb") as audioFile:
str = base64.b64encode(audioFile.read())
fifo.write(str)
Одновременно чтение и запись двух разных файлов:
# maker sure the be read file's has some data.
with open("a.file", "w") as fp:
fp.write("some data")
# now a.file has some data, we create a b.file for write the a.file's data.
with open("b.file", "w") as write_fp, open("a.file", "r") as read_fp:
write_fp.write(read_fp.read())
# for bytes data
with open("b.file", "wb") as write_fp, open("a.file", "rb") as read_fp:
write_fp.write(read_fp.read())