Have any ideas on a better loop?


#1

Im pretty new to python and am trying to find the most efficient loop to achieve multiple http requests, have any ideas?
heres an example of what im currently doing:

             fob = int( e.get())
             for line in itertools.islice(bot,fob1):
	       while True:					
	            lPAYLOAD= data		
		     q.put(lPAYLOAD)	

                        global consumer
		    def consumer():			
			  for line in pf:
			       	for times in itertools.repeat(pf,3):
					proxies = {'http':'http://'+line+''}
					q10.put(proxies)
					try:
						while True and not q.empty():
							nextTime = 0
							t = q.get()
							global req
							def req():


								proxies = q10.get()
								#print proxies
								url = random.choice(url1)
								#print url

								l = loginbots.post(url,t,proxies=proxies,headers=headers)
								print proxies
								with open(filename2,'ab') as m:
									if l.text == '{"result":"success","id":2}':
										pickle.dump(requests.utils.dict_from_cookiejar(loginbots.cookies),m)									
										color = colorselection1
										l13.configure(bg = color)
										botska()


								m.close()
								p_file.close()
								bot_file.close()


							tester1()

					except ValueError as e:
						print e
						pass
					except requests.exceptions.ReadTimeout:
						pass			
		break		
tester()
color = colorselection2
l13.configure(bg = color)
    def tester():
	try:

		tbl = Thread(name = 'daemon', target = consumer)
		tbl.setDaemon(True)
		tbl.start()
	except KeyError:
		pass
      def tester1():
	try:
		start = timer()
		global tyall
		tyall = Thread(name = 'daemon', target = req)
		tyall.setDaemon(True)
		tyall.start()
		end = timer()
		print(end - start)
	except KeyError:
		pass	

any suggestions are welcome :slightly_smiling: