Created
February 15, 2023 12:48
-
-
Save Geek-a-Byte/cd1c1e462e07fb09f57bbd868781edb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/58935672/i-get-brokenpipeerror-errno-32-broken-pipe-error-in-python | |
from requests.exceptions import ConnectionError | |
def retry_on_connectionerror(f, max_retries=5): | |
retries = 0 | |
while retries < max_retries: | |
try: | |
return f() | |
except ConnectionError: | |
retries += 1 | |
raise Exception("Maximum retries exceeded") | |
worksheet1.values_clear("tc id!A:B") | |
source_tc= client.open('tc_sheet') | |
source_tc.sheet1.delete_row(1) | |
new_values_tc = source_tc.values_get('Sheet1!A:B') | |
def update_values(): | |
worksheet1.values_update( | |
"tc id!A:B" | |
, | |
params={ | |
'valueInputOption': 'USER_ENTERED' | |
} , | |
body={ | |
'values': new_values_tc['values'] | |
} | |
) | |
retry_on_connectionerror(update_values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment