|
@@ -46,9 +46,7 @@ def parseSource(s):
|
|
|
t.start()
|
|
t.start()
|
|
|
threads.append(t)
|
|
threads.append(t)
|
|
|
|
|
|
|
|
-# print("Waiting for %d queue elements" % q.qsize())
|
|
|
|
|
q.join() # block until all tasks are done
|
|
q.join() # block until all tasks are done
|
|
|
-# print("Finished waiting for the queue")
|
|
|
|
|
|
|
|
|
|
for _ in range(num_worker_threads):
|
|
for _ in range(num_worker_threads):
|
|
|
# put num_worker empty jobs so
|
|
# put num_worker empty jobs so
|
|
@@ -106,12 +104,14 @@ def news_worker(source, kw, d, q):
|
|
|
q.task_done()
|
|
q.task_done()
|
|
|
|
|
|
|
|
|
|
|
|
|
-# TODO influx start
|
|
|
|
|
-
|
|
|
|
|
post_data('event', {}, '"start"')
|
|
post_data('event', {}, '"start"')
|
|
|
start = time()
|
|
start = time()
|
|
|
-sources = db().sources()
|
|
|
|
|
-db().purge_error()
|
|
|
|
|
|
|
+d = db()
|
|
|
|
|
+sources = d.sources()
|
|
|
|
|
+post_data('value', {'type': 'error'}, d.count_error())
|
|
|
|
|
+post_data('event', {}, '"purge_error_finish"')
|
|
|
|
|
+d.purge_error()
|
|
|
|
|
+
|
|
|
post_data('event', {}, '"purge_error_finish"')
|
|
post_data('event', {}, '"purge_error_finish"')
|
|
|
pool = Pool(processes=4)
|
|
pool = Pool(processes=4)
|
|
|
ret = pool.map(parseSource, sources)
|
|
ret = pool.map(parseSource, sources)
|
|
@@ -120,14 +120,12 @@ tot = sum([r[1] for r in ret])
|
|
|
|
|
|
|
|
post_data('value', {'type': 'new'}, new)
|
|
post_data('value', {'type': 'new'}, new)
|
|
|
post_data('value', {'type': 'total'}, tot)
|
|
post_data('value', {'type': 'total'}, tot)
|
|
|
-# TODO influx source new
|
|
|
|
|
-# TODO influx source total
|
|
|
|
|
# n = sum(ret)
|
|
# n = sum(ret)
|
|
|
# sret = sorted(ret, key=lambda tup: tup[0])
|
|
# sret = sorted(ret, key=lambda tup: tup[0])
|
|
|
# print(sret)
|
|
# print(sret)
|
|
|
|
|
|
|
|
print("[%s] %d/%d new articles, total time %d sec" %
|
|
print("[%s] %d/%d new articles, total time %d sec" %
|
|
|
(strftime("%H:%M:%S"), new, tot, time()-start))
|
|
(strftime("%H:%M:%S"), new, tot, time()-start))
|
|
|
|
|
+post_data('time', {'type': 'total'}, time()-start)
|
|
|
print("#" * 75)
|
|
print("#" * 75)
|
|
|
-# TODO influx end
|
|
|
|
|
post_data('event', {}, '"end"')
|
|
post_data('event', {}, '"end"')
|