You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
blob.upload_from_filename blocks for upwards of an hour. #3441
I am using the following code to upload files to GCS.
blob=bucket.blob(gcs_filepath)
logging.info('Uploading file "%s" to "%s".', filepath, gcs_filepath)
blob.upload_from_filename(filepath)
logging.info('Uploaded file "%s" to "%s".', filepath, gcs_filepath)
This works most of the time. However, it has been stuck uploading for the last hour and has not raised an exception yet. It seems like this method should have a timeout or something for situations like this. It would also be helpful if it had the option to log the progress of the method for further diagnosis.
@tweeter0830 I'm closing this out as that is the culprit. As @tseaver said, you'll want Client instances to be thread local (for now). We will soon be dumping httplib2 altogether (for requests).
Thanks for the snippet @GEverding. I'm not a regular user of Celery so I'm not sure what the implications are here. Are you saying you put this in a Python module at global scope and then point Celery at that module?
@dhermes Yes the function is in the global scope. We run each task on a separate process so there should only be one thread calling this piece of code.
@kain64 It appears you have a different issue than the original reporter. It's likely that the webbrowser GUI is using multiple threads to upload the file in chunks simultaneously (but I'm not sure).
If you'd really like fast uploads, I recommend looking into gsutil (we would like to speed up our uploads, but gsutil is fast today).
Activity
tseaver commentedon May 19, 2017
Duplicate of #3442, which has more information.
tseaver commentedon May 19, 2017
Hmm, not a duplicate.
dhermes commentedon May 19, 2017
@tseaver @tweeter0830 It may be somewhat of a duplicate if the real answer is that
httplib2+ threading == a bad time.tweeter0830 commentedon May 19, 2017
I am using this in a thread.
tseaver commentedon May 19, 2017
@tweeter0830 Or switch to using a separate
Clientinstance per thread (they should be relatively cheap to construct).dhermes commentedon May 19, 2017
@tweeter0830 I'm closing this out as that is the culprit. As @tseaver said, you'll want
Clientinstances to be thread local (for now). We will soon be dumpinghttplib2altogether (forrequests).tweeter0830 commentedon May 22, 2017
I moved the client into a single thread and I am still having this issue.
dhermes commentedon May 22, 2017
@tweeter0830 Can you provide some example code so we can discuss the implementation?
GEverding commentedon May 23, 2017
I'm seeing similar issues. I'm creating new Client Objects each time I want to upload a file.
This is running in a Celery Task.
dhermes commentedon May 23, 2017
Thanks for the snippet @GEverding. I'm not a regular user of Celery so I'm not sure what the implications are here. Are you saying you put this in a Python module at global scope and then point Celery at that module?
GEverding commentedon May 23, 2017
@dhermes Yes the function is in the global scope. We run each task on a separate process so there should only be one thread calling this piece of code.
tweeter0830 commentedon May 24, 2017
Sorry, I was mistaken. It appears to have fixed the issue.
kain64 commentedon Jun 14, 2017
same problem. 100mb upload ~3-4 minutes. using webbrouser gui ~less than 20 sec
dhermes commentedon Jun 14, 2017
@kain64 It appears you have a different issue than the original reporter. It's likely that the webbrowser GUI is using multiple threads to upload the file in chunks simultaneously (but I'm not sure).
If you'd really like fast uploads, I recommend looking into
gsutil(we would like to speed up our uploads, butgsutilis fast today).chore(deps): update dependency numpy to v1.18.3 [(#3441)](GoogleCloud…