2727def create_task (project , queue , location ):
2828 """Create a task for a given queue with an arbitrary payload."""
2929
30+ import googleapiclient .discovery
31+
3032 # Create a client.
31- from googleapiclient import discovery
32- client = discovery .build (
33- 'cloudtasks' , 'v2beta2' )
33+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
3434
3535 payload = 'a message for the recipient'
3636 task = {
@@ -54,10 +54,10 @@ def create_task(project, queue, location):
5454def pull_task (project , queue , location ):
5555 """Pull a single task from a given queue and lease it for 10 minutes."""
5656
57+ import googleapiclient .discovery
58+
5759 # Create a client.
58- from googleapiclient import discovery
59- client = discovery .build (
60- 'cloudtasks' , 'v2beta2' )
60+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
6161
6262 duration_seconds = '600s'
6363 pull_options = {
@@ -79,10 +79,10 @@ def pull_task(project, queue, location):
7979def acknowledge_task (task ):
8080 """Acknowledge a given task."""
8181
82+ import googleapiclient .discovery
83+
8284 # Create a client.
83- from googleapiclient import discovery
84- client = discovery .build (
85- 'cloudtasks' , 'v2beta2' )
85+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
8686
8787 body = {'scheduleTime' : task ['scheduleTime' ]}
8888 client .projects ().locations ().queues ().tasks ().acknowledge (
0 commit comments