python - How start multiple tasks at once in tornado -


i have for .. in .. : loop, calling methond waiting result. how can make loop start @ once , wait results?

this code:

@gen.coroutine def update_all( self ):     service in self.port_list:         response = yield self.update_service( str( service.get( 'port' ) ) )         self.response_list.append( response )      self.response = json.dumps( self.response_list )      return self.response 

thank you!

build list (of future objects returned update_service()), , yield list:

@gen.coroutine def update_all( self ):      futures = []     service in self.port_list:         futures.append(self.update_service(str(service.get('port'))))      self.response_list = yield futures     self.response = json.dumps( self.response_list )      return self.response 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -