Skip to content

Commit

Permalink
Fix BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
HanZhuoii committed Nov 18, 2020
1 parent cb18cdf commit 5d6b26f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def run(self):
question.spider(_id)
except:
continue
elif not self.id_manager.list_not_null("list_"+config.TOPIC_SET):
break
else:
sleep(5)
self.exit_code = 0
Expand Down Expand Up @@ -106,15 +104,13 @@ def run(self):
_id = ''
try:
logger.info("CommentSpider thread start...")
while True:
while self.flag:
if self.id_manager.list_not_null():
_id = self.id_manager.get()
try:
comment.spider(_id)
except:
continue
elif not (self.id_manager.list_not_null("list_"+config.TOPIC_SET) or self.id_manager.list_not_null("list_"+config.QUESTION_SET)):
break
else:
sleep(5)
self.exit_code = 0
Expand Down Expand Up @@ -146,15 +142,13 @@ def run(self):
logger.info("UserSpider thread start...")
_id = ''
try:
while True:
while self.flag:
if self.id_manager.list_not_null():
_id = self.id_manager.get()
try:
user.spider(_id)
except:
continue
elif not (self.id_manager.list_not_null("list_"+config.TOPIC_SET) or self.id_manager.list_not_null("list_"+config.QUESTION_SET) or self.id_manager.list_not_null("list_"+config.COMMENT_SET)):
break
else:
sleep(5)
self.exit_code = 0
Expand Down Expand Up @@ -266,6 +260,15 @@ def run(self):
return
if (TS.is_alive() or TS.exit_code == 0) and (QS.is_alive() or QS.exit_code == 0) and (CS.is_alive() or CS.exit_code == 0) and (US.is_alive() or US.exit_code == 0):
logger.info("----- ALL THREAD IS ALIVE -----")
if TS.exit_code == 0 and QS.id_manager.list_not_null():
if QS.flag:
QS.__exit__()
if QS.exit_code == 0 and CS.id_manager.list_not_null():
if CS.flag:
CS.__exit__()
if CS.exit_code == 0 and US.id_manager.list_not_null():
if US.flag:
US.__exit__()
sleep(10)


Expand Down

0 comments on commit 5d6b26f

Please sign in to comment.