#NEWLINE# def _DeliverMatches( self , subscriptions , match_request ) : #NEWLINE# #INDENT# 'Deliver list of subscriptions as batches using taskqueue.\n\n    Args:\n      subscriptions: list of subscription ids\n      match_request: MatchRequest\n    ' #NEWLINE# parameters = { #NEWLINE# #INDENT# 'topic' : match_request . topic ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# if match_request . has_result_python_document_class ( ) : #NEWLINE# #INDENT# python_document_class = match_request . result_python_document_class ( ) #NEWLINE# parameters [ 'python_document_class' ] = python_document_class #NEWLINE# parameters [ 'document' ] = base64 . urlsafe_b64encode ( match_request . document ( ) . Encode ( ) ) #NEWLINE# #UNINDENT# if match_request . has_result_key ( ) : #NEWLINE# #INDENT# parameters [ 'key' ] = match_request . result_key ( ) #NEWLINE# #UNINDENT# taskqueue_request = taskqueue_service_pb . TaskQueueBulkAddRequest ( ) #NEWLINE# batch_size = match_request . result_batch_size ( ) #NEWLINE# for i in xrange ( 0 , len ( subscriptions ) , batch_size ) : #NEWLINE# #INDENT# add_request = taskqueue_request . add_add_request ( ) #NEWLINE# add_request . set_queue_name ( match_request . result_task_queue ( ) ) #NEWLINE# add_request . set_task_name ( '' ) #NEWLINE# add_request . set_eta_usec ( 0 ) #NEWLINE# add_request . set_url ( match_request . result_relative_url ( ) ) #NEWLINE# add_request . set_description ( 'prospective_search::matches' ) #NEWLINE# header = add_request . add_header ( ) #NEWLINE# header . set_key ( 'content-type' ) #NEWLINE# header . set_value ( 'application/x-www-form-urlencoded; charset=utf-8' ) #NEWLINE# parameters [ 'results_count' ] = len ( subscriptions ) #NEWLINE# parameters [ 'results_offset' ] = i #NEWLINE# parameters [ 'id' ] = subscriptions [ i : ( i + batch_size ) ] #NEWLINE# add_request . set_body ( urllib . urlencode ( match_request , doseq = True ) ) #NEWLINE# #UNINDENT# taskqueue_response = taskqueue_service_pb . TaskQueueBulkAddResponse ( ) #NEWLINE# self . taskqueue_stub . _Dynamic_BulkAdd ( taskqueue_request , taskqueue_response )