Closed
Description
Environment details
- OS type and version: app engine flexible env
- Python version:
python --version 3.7
- pip version:
pip --version
- google-api-core==2.3.2
- google-cloud-core==2.2.1
- google-cloud-storage==1.43.0
- google-cloud-logging==2.7.0
- google-cloud-profiler==3.0.6
- google-cloud-tasks==2.7.1
Steps to reproduce
- this error is frequently coming when creating a google cloud task
Code example
def create_task(queue, url_name, args=None, kwargs=None, payload=None, in_seconds=None):
task = {
'app_engine_http_request': { # Specify the type of request.
'http_method': 'POST',
'relative_uri': reverse(url_name, args=args, kwargs=kwargs),
"headers": {
"Content-Type": "text/plain"
}
}
}
if payload is not None:
payload = json.dumps(payload)
converted_payload = payload.encode()
task['app_engine_http_request']['body'] = converted_payload
if in_seconds is not None:
# Convert "seconds from now" into an rfc3339 datetime string.
d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
# Create Timestamp protobuf.
timestamp = timestamp_pb2.Timestamp()
timestamp.FromDatetime(d)
# Add the timestamp to the tasks.
task['schedule_time'] = timestamp
# client = tasks_v2.CloudTasksClient()
# Construct the fully qualified queue name.
parent = tasks_client.queue_path(PROJECT, LOCATION, queue)
# Use the client to build and send the task.
response = tasks_client.create_task(parent=parent, task=task)
return response
Stack trace
File "/home/vmagent/app/utils/tasks.py", line 119, in create_task
response = tasks_client.create_task(parent=parent, task=task)
File "/env/lib/python3.6/site-packages/google/cloud/tasks_v2/services/cloud_tasks/client.py", line 1712, in create_task
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "/env/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py", line 154, in __call__
return wrapped_func(*args, **kwargs)
File "/env/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 68, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
File "/env/lib/python3.6/site-packages/google/api_core/exceptions.py", line 537, in from_grpc_error
if isinstance(rpc_exc, grpc.Call) or _is_informative_grpc_error(rpc_exc):
AttributeError: 'NoneType' object has no attribute 'Call'