Closed Chasikanaft closed 2 years ago
aiofiles.os.sendfiles
not found. Error:AttributeError: module 'aiofiles.os' has no attribute 'sendfile'
pip freeze
result:aiofiles==22.1.0 asyncio==3.4.3 types-aiofiles==22.1.0
or another method copy file to dir like a link? im newbie of python
so Python version - 3.9.4
Try aiofiles.io.sendfile
instead of sendfiles
? Sendfile is an advanced function though, definitely not for newbies. Not sure what you're trying to accomplish.
Try
aiofiles.io.sendfile
instead ofsendfiles
? Sendfile is an advanced function though, definitely not for newbies. Not sure what you're trying to accomplish.
aiofiles.io.sendfile
not found too. Its seems to be right, copy buffer with read()
function andwrite()
to destination file?
Er sorry, it's aiofiles.os.sendfile
.
But for simple file copying, you can look at https://docs.python.org/3/library/shutil.html#shutil.copyfile. We don't have an async version of that, so you'll have to run it in a background thread yourself, something like: asyncio.get_running.loop().run_in_executor(None, shutil.copyfile, arg1, arg2)
Thanks! can you tell me how to call this function so that it does not block the main thread? the call is made from a synchronous function?)
You use run_in_executor
like in my snippet. That'll run it in a thread
RuntimeError: no running event loop
error, I think this error is caused by the fact that my function from which I have to call the copy method belongs to a class (not asynchronous).
Can you suggest how to do it right? I need to call in parallel the functions of copying and viewing the status of copied files (stats) for the progress bar status
Hey, this is getting out of scope for this project now. You should try stack overflow!
aiofiles.os.sendfiles
not found. Error:AttributeError: module 'aiofiles.os' has no attribute 'sendfile'
pip freeze
result:or another method copy file to dir like a link? im newbie of python