Potentially instead of the loop here we could do a solr query like.
'q': 'id:id1 or id:id2 or id:id3 ...'
which would stop so many round trips.

However we would need to limit the amount of records we do in one query as solr (actually the webserver) has a request size limit we have faced before.