common.create_task: only log in local server, don't actually create task

pull/640/head
Ryan Barrett 2023-09-09 07:51:54 -07:00
rodzic ee3b72fb1e
commit efcd2d89b4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 16 dodań i 11 usunięć

Wyświetl plik

@ -13,6 +13,7 @@ from Crypto.Util import number
from flask import abort, g, make_response, request from flask import abort, g, make_response, request
from oauth_dropins.webutil import util, webmention from oauth_dropins.webutil import util, webmention
from oauth_dropins.webutil.appengine_config import tasks_client from oauth_dropins.webutil.appengine_config import tasks_client
from oauth_dropins.webutil import appengine_info
from oauth_dropins.webutil.appengine_info import APP_ID, DEBUG from oauth_dropins.webutil.appengine_info import APP_ID, DEBUG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -229,14 +230,18 @@ def create_task(queue, **params):
params: form-encoded and included in the task request body params: form-encoded and included in the task request body
""" """
assert queue assert queue
task = tasks_client.create_task(
parent=tasks_client.queue_path(APP_ID, TASKS_LOCATION, queue), if appengine_info.LOCAL_SERVER:
task={ logger.info(f'Would add task: {queue} {params}')
'app_engine_http_request': { else:
'http_method': 'POST', task = tasks_client.create_task(
'relative_uri': f'/_ah/queue/{queue}', parent=tasks_client.queue_path(APP_ID, TASKS_LOCATION, queue),
'body': urllib.parse.urlencode(params).encode(), task={
'headers': {'Content-Type': 'application/x-www-form-urlencoded'}, 'app_engine_http_request': {
}, 'http_method': 'POST',
}) 'relative_uri': f'/_ah/queue/{queue}',
logger.info(f'Added {queue} task {task.name} : {params}') 'body': urllib.parse.urlencode(params).encode(),
'headers': {'Content-Type': 'application/x-www-form-urlencoded'},
},
})
logger.info(f'Added {queue} task {task.name} : {params}')