Kaydet (Commit) 06e9730b authored tarafından jorendc's avatar jorendc Kaydeden (comit) Markus Mohrhard

Add basic multi-threading for each mimetype

Change-Id: Ife0766ddd259bb7d86a9c7bdcf3e9c2849208cf0
Reviewed-on: https://gerrit.libreoffice.org/7123Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 247cd338
...@@ -27,6 +27,7 @@ import re ...@@ -27,6 +27,7 @@ import re
import os, os.path import os, os.path
import stat import stat
import sys import sys
import threading, Queue
try: try:
from urllib.request import urlopen from urllib.request import urlopen
except: except:
...@@ -450,14 +451,55 @@ common_noncore_mimetypes = { ...@@ -450,14 +451,55 @@ common_noncore_mimetypes = {
'application/pdf': 'pdf', 'application/pdf': 'pdf',
} }
for (prefix, uri) in rss_bugzillas.items(): class manage_threads(threading.Thread):
for (mimetype,extension) in mimetypes.items(): def run(self):
# It seems that bugzilla has problems returing that many results #print(threading.current_thread().get_ident())
# (10000 results is probably a limit set somewhere) so we always while 1:
# end processing the complete list. # Try to receive a job from queue
if mimetype == 'text/html' and prefix == 'moz': try:
continue # Get job from queue
get_through_rss_query(uri, mimetype, prefix, extension) # Use job parameters to call our query
# Then let the queue know we are done with this job
job = jobs.get(True,5)
get_through_rss_query(job[0], job[1], job[2], job[3]) # [0] = uri; [1] = mimetype; [2] = prefix; [3] = extension
jobs.task_done()
except KeyboardInterrupt:
raise # Ctrl+C should work
except:
break
def generate_multi_threading():
for (prefix, uri) in rss_bugzillas.items():
# Initialize threads
for i in xrange(max_threads):
manage_threads().start()
# Create a job for every mimetype for a bugzilla
for (mimetype,extension) in mimetypes.items():
# It seems that bugzilla has problems returing that many results
# (10000 results is probably a limit set somewhere) so we always
# end processing the complete list.
if mimetype == 'text/html' and prefix == 'moz':
continue
try:
jobs.put([uri, mimetype, prefix, extension], block=True, timeout=3)
print("successfully placed a job in the queue searching for " + mimetype + "in bugtracker " + prefix)
except KeyboardInterrupt:
raise # Ctrl+C should work
except:
print("Queue full")
# Continue when all mimetypes are done for a bugzilla
jobs.join()
max_threads = 20 # Number of threads to create, (1 = without multi-threading)
jobs = Queue.Queue(40)
generate_multi_threading()
for (mimetype,extension) in mimetypes.items(): for (mimetype,extension) in mimetypes.items():
get_through_rpc_query(redhatrpc, redhatbug, mimetype, "rhbz", extension) get_through_rpc_query(redhatrpc, redhatbug, mimetype, "rhbz", extension)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment