mirror of https://github.com/testerSunshine/12306
优化睡眠时间,队列循环提交
parent
dffc307b55
commit
f07b33d099
|
@ -33,7 +33,7 @@ class select:
|
||||||
self.user_info = ""
|
self.user_info = ""
|
||||||
self.secretStr = ""
|
self.secretStr = ""
|
||||||
self.ticket_black_list = dict()
|
self.ticket_black_list = dict()
|
||||||
self.submitQueue=Queue.Queue(20)
|
self.submitQueue=Queue.Queue(2)
|
||||||
|
|
||||||
def get_ticket_info(self):
|
def get_ticket_info(self):
|
||||||
"""
|
"""
|
||||||
|
@ -623,6 +623,7 @@ class select:
|
||||||
def main(self):
|
def main(self):
|
||||||
from_station, to_station = self.station_table(self.from_station, self.to_station)
|
from_station, to_station = self.station_table(self.from_station, self.to_station)
|
||||||
if self.leftTicketLog(from_station, to_station):
|
if self.leftTicketLog(from_station, to_station):
|
||||||
|
submitOrderConsumer("daemon1",self.submitQueue).start()
|
||||||
num = 1
|
num = 1
|
||||||
runedTime=0
|
runedTime=0
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -669,13 +670,15 @@ class selectProducer(threading.Thread):
|
||||||
self.worker(self.data)
|
self.worker(self.data)
|
||||||
|
|
||||||
def worker(self,data):
|
def worker(self,data):
|
||||||
if data.obj.check_user():
|
obj=data['obj']
|
||||||
data.obj.submit_station()
|
if obj.check_user():
|
||||||
data.obj.getPassengerTicketStr(self._station_seat[j].encode("utf8"))
|
obj.submit_station()
|
||||||
data.obj.getRepeatSubmitToken()
|
obj.getPassengerTicketStr(data['seat'])
|
||||||
data.obj.user_info = self.getPassengerDTOs()
|
obj.getRepeatSubmitToken()
|
||||||
if data.obj.checkOrderInfo(data.train_no, data.seat):
|
obj.user_info = obj.getPassengerDTOs()
|
||||||
|
if obj.checkOrderInfo(data['train_no'], data['seat']):
|
||||||
return
|
return
|
||||||
|
obj.submitQueue.task_done()
|
||||||
|
|
||||||
|
|
||||||
class submitOrderConsumer(threading.Thread):
|
class submitOrderConsumer(threading.Thread):
|
||||||
|
@ -689,7 +692,7 @@ class submitOrderConsumer(threading.Thread):
|
||||||
while 1:
|
while 1:
|
||||||
if not self.data.empty():
|
if not self.data.empty():
|
||||||
taskData=self.data.get()
|
taskData=self.data.get()
|
||||||
selectProducer('submit_'+str(random.random),taskData).start()
|
selectProducer(taskData['train_no']+str(random.random()),taskData).start()
|
||||||
else:
|
else:
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue