을, 당신은 메인 스레드가 계속하면서 작업을 폴링하는 별도의 스레드를 사용할 수 있습니다. 또는 반환 된 작업의 operation.name
을 별도의 서비스에 전달하고 다른 서비스에서 폴링을 처리하도록 할 수 있습니다. 실제로 장기 실행 작업을 호출하는 서비스는 예를 들어 Pub/Sub 항목에 operation.name
을 게시 할 수 있습니다.
{u'done': True,
u'metadata': {u'@type': u'type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata',
u'lastUpdateTime': u'2017-06-21T19:38:14.522280Z',
u'progressPercent': 100,
u'startTime': u'2017-06-21T19:38:13.599009Z'},
u'name': u'...................',
u'response': {u'@type': u'type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse',
u'results': [{u'alternatives': [{u'confidence': 0.987629,
u'transcript': u'how old is the Brooklyn Bridge'}]}]}}
: 작업이 완료되면
from oauth2client.client import GoogleCredentials
from googleapiclient import discovery
credentials = GoogleCredentials.get_application_default()
speech_service = discovery.build('speech', 'v1', credentials=credentials)
operation_name = .... # operation.name
get_operation_request = speech_service.operations().get(name=operation_name)
# response is a dictionary
response = get_operation_response.execute()
# handle polling
retry_count = 100
while retry_count > 0 and not response.get('done', False):
retry_count -= 1
time.sleep(60)
response = get_operation_response.execute()
하기는 response
DICT는 다음과 같은 형태가 될 것이다 : 아래
이름으로 그것을보고 긴 실행 작업을 검색하는 가능한 방법입니다