I am sorry about that. Not sure how 10 became a floating - it was "10" when I posted. Here's my complete code. I have not included the url but you can assume it is an API call. Also, I have a list of devices in the file "filtered_devices".
import urllib import urllib2 import requests import threading import Queue #Queuing q = Queue.LifoQueue() url = 'x' def queue_interfaces(q): #grabs the queue and starts getting the interfaces from the list while not q.empty(): headers = {"Content-Type": "application/json"} a = str(q.get()).strip('\n') data = {"data":{"Type":"Interfaces","Filters":{"device__name":a},"Attributes":["speed","status__name"],"page_size":10}} r = requests.post(url, headers=headers, json=data) #print (r.text) f = open("interfaceslistfinal", 'w') f.write(r.text) q.task_done() f.close() with open("filtered_devices") as my_file: for line in my_file: q.put(line) q.join() #Threading numofThreads = 10 #threadlist = [] for i in range (numofThreads): print i t = threading.Thread(target = queue_interfaces, args=(q,)) t.setDaemon(True) t.start()