Use Service Accounts for Cloning if availble.

- increase default timeout for network socket interface

Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
jaskaranSM 2020-03-24 09:59:26 +05:30 committed by lzzy12
parent 6181b022ac
commit be9c64a9aa
2 changed files with 17 additions and 1 deletions

View File

@ -6,6 +6,9 @@ import time
import aria2p
import telegram.ext as tg
from dotenv import load_dotenv
import socket
socket.setdefaulttimeout(600)
botStartTime = time.time()
if os.path.exists('log.txt'):

View File

@ -228,7 +228,20 @@ class GoogleDriveHelper:
body = {
'parents': [dest_id]
}
return self.__service.files().copy(supportsAllDrives=True, fileId=file_id, body=body).execute()
try:
res = self.__service.files().copy(supportsAllDrives=True,fileId=file_id,body=body).execute()
return res
except HttpError as err:
if err.resp.get('content-type', '').startswith('application/json'):
reason = json.loads(err.content).get('error').get('errors')[0].get('reason')
if reason == 'userRateLimitExceeded' or reason == 'dailyLimitExceeded':
if USE_SERVICE_ACCOUNTS:
self.switchServiceAccount()
LOGGER.info(f"Got: {reason}, Trying Again.")
self.copyFile(file_id,dest_id)
else:
raise err
def clone(self, link):
self.transferred_size = 0