Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async file upload #84

Open
MrWillTurner opened this issue Sep 29, 2023 · 2 comments
Open

async file upload #84

MrWillTurner opened this issue Sep 29, 2023 · 2 comments

Comments

@MrWillTurner
Copy link

Hi. I am trying to use the module asyncio to asynchronously upload files to my pcloud folder but it always blocks waits for the upload to be terminate before doing the next line

Do you have any idea of what I'm doing wrong ?

from dotenv import load_dotenv
import os
import asyncio


async def call_this(connection,file):
    await uploadfile(connection,file)

async def uploadfile(connection,file):
    await connection.uploadfile(files = file)
    print("done")

load_dotenv()

pcloud_user = os.environ.get("PCLOUD_USER")
pcloud_password = os.environ.get("PCLOUD_PASSWORD")

connection = PyCloud(pcloud_user, pcloud_password)



asyncio.run(call_this(connection,["test.png","test2.png"]))
@tomgross
Copy link
Owner

Hi @MrWillTurner thanks for your report. The PCloud library uses the synchronous request-library. There is an asynchronous one. I assume there is some blocking/unblocking magic involved, which prevents your code example from working.

If you interested in an async version of pCloud you have several options:

Implement it yourself and submit a pull request.
Wait until I have time and interest to implement it.
Pay me (or someone else) to implement it. My contact details are on my homepage: https://tomgross.github.io/

If you use and ❤️ my software, consider buying me a coffee ☕ https://www.paypal.com/paypalme/tomgross42

@mokko
Copy link

mokko commented Oct 28, 2023

In the video below Arjan recommends using request with asyncio.to_thread. Might work here too.
https://www.youtube.com/watch?v=GpqAQxH1Afc

Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants