Redirect asyncio subprocess to file

I would like to execute some long-running process via asyncio.create_subprocess_exec and redirect its output to file. File should be also closed when process is finished, and I would like not to create separate thread waiting for process to finish to achieve this. I'm trying to read docs, but a file-like object representing a pipe to be connected to the subprocess’s standard input stream using connect_write_pipe() is very enigmatic for someone from outside python duck-typing world. Is there any way to achieve this (maybe some external asyncio util lib)?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum