in amazon_polly_async_batch/itemprocessor.py [0:0]
def process_item(item):
"""
Given a work item consisting of text to synthesize, submits to Polly and tracks the response in DynamoDb.
Retries up to 10 times if Polly is throttling us.
:param item: a dictionary with details on a snippet of text to synthesize
:return: the task ID assigned by Polly, or None if Polly refused the work
"""
item_name = item.get('output-file', '[unidentified]')
task_table = dynamo.TaskTable(TASK_TABLE)
try:
polly_task = submit_item_to_polly(item)
task_table.put_new_task(polly_task, item, 'Task submitted')
logger.debug('Posted item {} as polly task {}'.format(item_name, polly_task['TaskId']))
return polly_task['TaskId']
except Exception as e:
logger.error('Failed to post item {} as polly task because {}'.format(item_name, str(e)))
task_table.put_failed_task(item, str(e))
dynamo.SetTable(SET_TABLE).post_failure(item['set-name'])
return None