Skip to content
Snippets Groups Projects
Commit 2b9ced37 authored by Christian's avatar Christian
Browse files

Database sync now throttled such that only 20 threads do work at once - no...

Database sync now throttled such that only 20 threads do work at once - no longer tries to do ALL threads at the same time as that was a little extreme and offered no benefit.
parent c800e9ed
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ def sync_database(): ...@@ -14,7 +14,7 @@ def sync_database():
import lxml import lxml
import multiprocessing import multiprocessing
import sys import sys
import time
sys.setrecursionlimit(100000) sys.setrecursionlimit(100000)
#Get old links by parsing properly, and download + save to file! #Get old links by parsing properly, and download + save to file!
...@@ -37,7 +37,6 @@ def sync_database(): ...@@ -37,7 +37,6 @@ def sync_database():
def hasstylenotclass(tag): def hasstylenotclass(tag):
return tag.has_attr('style') and not tag.has_attr('class') return tag.has_attr('style') and not tag.has_attr('class')
for col in soup.tbody.find_all("tr"): for col in soup.tbody.find_all("tr"):
#print(row) #print(row)
#for col in row("tr"): #for col in row("tr"):
...@@ -88,14 +87,13 @@ def sync_database(): ...@@ -88,14 +87,13 @@ def sync_database():
q = multiprocessing.Queue() q = multiprocessing.Queue()
pool = multiprocessing.Pool(len(eventlinks),process,(q,)) pool = multiprocessing.Pool(len(eventlinks),process,(q,))
for i,link in enumerate(eventlinks): for i,link in enumerate(eventlinks):
while q.qsize() > 20:
time.sleep(1)
q.put([link,eventnames[i]]) q.put([link,eventnames[i]])
pool.close() pool.close()
pool.join() pool.join()
print('rm files')
for file in os.listdir(): for file in os.listdir():
if 'ToRead' in file: if 'ToRead' in file:
os.remove(file) os.remove(file)
# if i == 0: #sync_database()
# break \ No newline at end of file
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment