Как сделать запросы к google sheets api асинхронными?

Вот пример работы с google sheets api:

import httplib2
import googleapiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials

CREDENTIALS_FILE = 'creds.json'
spreadsheet_id = 'SPREADSHEETID'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    CREDENTIALS_FILE,
    ['https://www.googleapis.com/auth/spreadsheets',
     'https://www.googleapis.com/auth/drive'])
httpAuth = credentials.authorize(httplib2.Http())
service = googleapiclient.discovery.build('sheets', 'v4', http = httpAuth)

values = service.spreadsheets().values().get(
    spreadsheetId=spreadsheet_id,
    range='B3:C3',
    majorDimension='COLUMNS'
).execute()

values_write = service.spreadsheets().values().batchUpdate(
    spreadsheetId=spreadsheet_id,
    body={
        "valueInputOption": "USER_ENTERED",
        "data": [
            {"range": "B3:C3",
             "majorDimension": "ROWS",
             "values": [["C++", "Python"]]},
 ]
    }
).execute()

Как сделать эти вызовы асинхронными?


Ответы (0 шт):