Skip to content

Commit

Permalink
Change indexing thread to daemon to Fix #227.
Browse files Browse the repository at this point in the history
  • Loading branch information
machawk1 committed Nov 9, 2015
1 parent 5296aa1 commit 4eda649
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions bundledApps/WAIL.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ def __init__(self):
self.Notebook.AddPage(self.advConfig, tabLabel_advanced)
self.createMenu()

threading.Timer(INDEX_TIMER_SECONDS,Wayback().index).start()
print "scheduled!"
self.indexingTimer = threading.Timer(INDEX_TIMER_SECONDS,Wayback().index)
self.indexingTimer.daemon = True
self.indexingTimer.start()
def createMenu(self):
self.menu_bar = wx.MenuBar()
self.help_menu = wx.Menu()
Expand Down Expand Up @@ -261,7 +262,11 @@ def ensureCorrectInstallation(self):
#sys.exit()

def quit(self, button):
sys.exit()
print "Quitting!"
if mainAppWindow.indexingTimer:
mainAppWindow.indexingTimer.cancel()
#os._exit(0) #Quit without buffer cleanup
sys.exit(1) #Be a good citizen. Cleanup your memory footprint


class WAILGUIFrame_Basic(wx.Panel):
Expand Down Expand Up @@ -297,16 +302,16 @@ def __init__(self, parent):
def setMementoCount(self, count):
if hasattr(self,'status'):
self.status.Destroy()
self.status = wx.HyperlinkCtrl(self, -1, label=str(count) + " mementos available", url=" ", pos=(5, 65), size=(300,20))
self.status.SetNormalColour(wx.Colour(0,0,255))
self.status.SetVisitedColour(wx.Colour(0,0,255))
self.status.SetHoverColour(wx.Colour(0,0,255))
#self.status = wx.HyperlinkCtrl(self, -1, label=str(count) + " mementos available", url=" ", pos=(5, 65), size=(300,20))
#self.status.SetNormalColour(wx.Colour(0,0,255))
#self.status.SetVisitedColour(wx.Colour(0,0,255))
#self.status.SetHoverColour(wx.Colour(0,0,255))
self.status = wx.StaticText(self, -1, label=str(count) + " mementos available", pos=(5, 65), size=(300,20))

def setMessage(self, msg):
if hasattr(self,'status'):
self.status.Destroy()
self.status = wx.StaticText(self, -1, "", pos=(5, 65), size=(300,20))
self.status.SetLabel(msg)
self.status = wx.StaticText(self, -1, msg, pos=(5, 65), size=(300,20))

def fetchMementos(self):
# TODO: Use CDXJ for counting the mementos
Expand Down Expand Up @@ -410,7 +415,7 @@ def javaInstalled(self):
return (noJava not in stdout) and (noJava not in stderr)

def launchHeritrix(self):
cmd = heritrixBinPath+" -a "+heritrixCredentials_username+":"+heritrixCredentials_password
cmd = heritrixBinPath + " -a " + heritrixCredentials_username + ":" + heritrixCredentials_password
#TODO: shell=True was added for OS X, verify that functionality persists on Win64
ret = subprocess.Popen(cmd, shell=True)
time.sleep(3)
Expand Down Expand Up @@ -544,7 +549,6 @@ def setHeritrixStatus(self, status):
rowHeight = 20
col1 = 65+colWidth*1
cellSize = (40, rowHeight)
serviceEnabled = {True: serviceEnabledLabel_YES, False: serviceEnabledLabel_NO}

if hasattr(self,'status_heritrix'):
self.status_heritrix.Destroy()
Expand All @@ -555,7 +559,6 @@ def setWaybackStatus(self, status):
rowHeight = 20
col1 = 65+colWidth*1
cellSize = (40, rowHeight)
serviceEnabled = {True: serviceEnabledLabel_YES, False: serviceEnabledLabel_NO}

if hasattr(self,'status_wayback'):
self.status_wayback.Destroy()
Expand Down Expand Up @@ -988,7 +991,7 @@ def toggleTomcat(self, button, suppressAlert=False): #Optimize me, Seymour

def launchHeritrix(self, button):
#self.heritrixStatus.SetLabel("Launching Heritrix")
cmd = heritrixBinPath+" -a "+heritrixCredentials_username+":"+heritrixCredentials_password
cmd = heritrixBinPath + " -a " + heritrixCredentials_username + ":" + heritrixCredentials_password
#TODO: shell=True was added for OS X, verify that functionality persists on Win64
ret = subprocess.Popen(cmd, shell=True)
time.sleep(6) #urlib won't respond to https, hard-coded sleep until I can ping like Tomcat
Expand Down Expand Up @@ -1154,7 +1157,11 @@ def generateCDX(self):
print "Done creating sorted CDX file!"

# Queue next iteration of indexing
threading.Timer(INDEX_TIMER_SECONDS,Wayback().index).start()
if mainAppWindow.indexingTimer:
mainAppWindow.indexingTimer.cancel()
mainAppWindow.indexingTimer = threading.Timer(INDEX_TIMER_SECONDS,Wayback().index)
mainAppWindow.indexingTimer.daemon = True
mainAppWindow.indexingTimer.start()

class Tomcat(Service):
uri = uri_wayback
Expand Down

0 comments on commit 4eda649

Please sign in to comment.