Skip to content

Commit

Permalink
Update Google Tasks client
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroCool2u committed Jun 17, 2023
1 parent 6330bbf commit f0f4d8f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dash.exceptions import PreventUpdate
from datetime import datetime as dt
from google.cloud import firestore
from google.cloud import tasks as gtasks
from google.cloud import tasks_v2 as gtasks
from google.cloud.exceptions import NotFound
from google.protobuf import timestamp_pb2
from orjson import dumps
Expand Down Expand Up @@ -178,7 +178,7 @@ def schedule_fact_tasks(target_phone: str, target_name: str, fact_type: str, sta
# Construct the request body.
task = {
'app_engine_http_request': { # Specify the type of request.
'http_method': 'POST',
'http_method': gtasks.HttpMethod.POST,
'relative_uri': '/send'
}
}
Expand All @@ -193,16 +193,16 @@ def schedule_fact_tasks(target_phone: str, target_name: str, fact_type: str, sta
queue = 'facts-queue'
location = 'us-east4'
# Construct the fully qualified queue name.
parent = client.queue_path(project, location, queue)
parent = client.queue_path(project=project, location=location, queue=queue)

for t in tasks:
try:
# Use the client to build and send the task.
response = client.create_task(parent, t)
response = client.create_task(parent=parent, task=t)
logging.info('Task creation response: ' + str(response.name))

except Exception as e:
logging.warning('Exception while scheduling task: ' + str(e))
logging.error('Exception while scheduling task: ' + str(e))

return len(tasks)

Expand Down

0 comments on commit f0f4d8f

Please sign in to comment.