Closed nice-shot closed 2 years ago
@nice-shot what happens if you terminate it? does it print a stack trace, could you please share it?
@nice-shot one more question - do you provide a custom settings.yaml
file? what settings does it have? specifically, do you use save_credentials
option or not? If not, could you please try to enable it as described here https://docs.iterative.ai/PyDrive2/oauth/#automatic-and-custom-authentication-with-settings-yaml ?
This is the settings.yaml file:
client_config_backend: file
save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json
get_refresh_token: True
Unfortunately, because of the threads I can't seem to terminate the script using Ctrl-C. I have to close the terminal window so I don't get a stack trace. Based on the log I can see that the hanging threads reach one of the following lines:
f.GetContentFile(output_path)
or
for f in files.GetList():
Before emitting the "access_token is expired" log message and then stop writing any further logs.
Hmm, I can't reproduce this, that's what I see:
2022-04-03 19:35:36 T2 INFO access_token is expired. Now: 2022-04-04 02:35:36.493511, token_expiry: 2022-04-04 02:35:36.464825
2022-04-03 19:35:36 T2 INFO access_token is expired. Now: 2022-04-04 02:35:36.494126, token_expiry: 2022-04-04 02:35:36.464825
2022-04-03 19:35:36 T1 INFO access_token is expired. Now: 2022-04-04 02:35:36.494502, token_expiry: 2022-04-04 02:35:36.464825
2022-04-03 19:35:36 T1 INFO access_token is expired. Now: 2022-04-04 02:35:36.494678, token_expiry: 2022-04-04 02:35:36.464825
2022-04-03 19:35:36 T2 INFO Refreshing access_token
2022-04-03 19:35:36 T1 INFO Refreshing access_token
2022-04-03 19:35:36 T1 ERROR Error downloading folder: 46 - retry: 1
2022-04-03 19:35:36 T1 ERROR release unlocked lock
2022-04-03 19:35:46 T1 INFO Reading folder: 46 into 22/46
....
Do you also have this release unlocked lock
error? What OS and filesystem do you use? What is your Python version?
Yes I do get the release unlocked lock error, but the threads that show it keep working afterwards. I have windows 10, python version 3.71 and I’m running the script on an external exFat drive.
@nice-shot should be fixed in #164 I hope, give us some time to test it. Thanks for the report, it's indeed a critical non thread safety issue.
@nice-shot for the record - 1.10.1 was released on PyPi and conda
I've tested the new version and it seems to be working now! Thanks! I do sometimes get HttpError 500 but it's solved after one retry and I suppose that's more to do on Google's side.
I've wrote a script to download a google folder and all of its subfolders. I'm using this script to create a backup for a large folder hierarchy and running it with multiple threads. The script uses a queue that stores drive folder ids and the corresponding local folder path to download them to. Each thread takes one of these items, starts downloading the files inside (it also checks if a file exists and skips it if the MD5 matches) and inserts any folders it finds into the queue.
Once the script runs for more than an hour the following log message appears in several threads:
access_token is expired. Now: 2022-03-25 17:02:54.541287, token_expiry: 2022-03-25 17:02:54.164462
Following it, this log message appears in one of the threads:Refreshing access_token
The problem is that after this message appears, one or more of the threads starts hanging and will not continue execution. I'm not sure if it's an issue on my side or something about the way the token is renewed that causes this issue.
What can be causing these threads the hang? From my logs It doesn't seem like they're throwing an error or something...
This is the script's code: