Open arty-hlr opened 5 years ago
Even weirder, running the same list(client.item(drive='me', id=item.id).download(filename))
on another laptop, I now get:
File "download.py", line 113, in <module>
main()
File "download.py", line 108, in main
download_all(client)
File "download.py", line 77, in download_all
download_all(client, item.id)
File "download.py", line 77, in download_all
download_all(client, item.id)
File "download.py", line 77, in download_all
download_all(client, item.id)
File "download.py", line 91, in download_all
returned = list(client.item(drive='me', id=item.id).download_async(filename))
File "/usr/lib/python3.7/site-packages/onedrivesdk/request/item_request_builder.py", line 148, in download_async
entity = yield from self.content.request().download_async(local_path)
File "/usr/lib/python3.7/site-packages/onedrivesdk/request/item_content_request.py", line 102, in download_async
yield from future
RuntimeError: await wasn't used with future
which is the same kind of error, but now it does download for a few seconds while giving that error and than crashes!
Can you change your title to:
"await wasn't used with future" and "yield from wasn't used with future" errors with downloading large files with download_async? It's a lot more clear and I think you might get a bit more help.
Also on the second one, basically it's saying instead of yield from future
yield from await future
should've been used.
Looking at the examples, it is downloading, but I think it's doing it in the background. Have you tried something like the async example?
import asyncio
@asyncio.coroutine
def run_gets(client):
coroutines = [client.drive('me').request().get_async() for i in range(3)]
for future in asyncio.as_completed(coroutines):
drive = yield from future
print(drive.id)
loop = asyncio.get_event_loop()
loop.run_until_complete(run_gets(client))
When you called download()
I think it automatically sensed it was a large file and switched to download_async()
.
This code example may or may not work:
import asyncio
@asyncio.coroutine
def run_gets(client):
coroutines = [client.item(drive='me', id=item.id).download_async(filename)]
for future in asyncio.as_completed(coroutines):
print("Completed.")
loop = asyncio.get_event_loop()
loop.run_until_complete(run_gets(client))
Okay, this works:
import asyncio
# Make sure you've authenticated
def download(client, drivename, localname):
loop = asyncio.get_event_loop()
loop.run_until_complete(client.item(drive='me', path=drivename).download_async(localname))
download(client, "largefile.whatever", "downloadedfile.whatever")
I haven't tested it on a large file yet but it worked just fine on my test file.
Hi,
I'm trying to download files from my OneDrive, and at times I get this:
which I saw in other issues for uploading errors where it was advised to use
upload_async
instead ofupload
.Trying the same with
download_async
, just changing fromclient.item(drive='me', id=item.id).download(filename)
toclient.item(drive='me', id=item.id).download_async(filename)
just goes through it without downloading, and changing it toreturned = list(client.item(drive='me', id=item.id).download(filename))
(using to_dict() as mentioned in #51 doesn't work) gives me this:which I can't really make sense of.
Are there any other methods to download large files, or am I doing it wrong with
download_async
? Weirdly, I saw a lot of issues aboutupload_async
, but none about that.Thanks in advance for the help!