diff --git a/gui/builtinStatsViews/priceViewFull.py b/gui/builtinStatsViews/priceViewFull.py index 443edbc0f..cbe7ba277 100644 --- a/gui/builtinStatsViews/priceViewFull.py +++ b/gui/builtinStatsViews/priceViewFull.py @@ -36,7 +36,7 @@ class PriceViewFull(StatsView): self._timerRuns = 0 self._timerIdUpdate = wx.NewId() self._timerUpdate = None - + def OnTimer( self, event): if self._timerId == event.GetId(): if self._timerRuns >= self._timerRunsBeforeUpdate: @@ -81,7 +81,7 @@ class PriceViewFull(StatsView): hbox.Add(lbl, 0, wx.ALIGN_LEFT) hbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, " ISK"), 0, wx.ALIGN_LEFT) - self.labelEMStatus = wx.StaticText(contentPanel, wx.ID_ANY, "") + self.labelEMStatus = wx.StaticText(contentPanel, wx.ID_ANY, "") contentSizer.Add(self.labelEMStatus,0) def refreshPanel(self, fit): if fit is not None: diff --git a/service/market.py b/service/market.py index c972b63ab..3b50cd02a 100644 --- a/service/market.py +++ b/service/market.py @@ -23,48 +23,28 @@ import wx import collections import threading from sqlalchemy.orm.exc import NoResultFound +import Queue class PriceWorkerThread(threading.Thread): def run(self): - self.cv = threading.Condition() - self.updateRequests = collections.deque() - self.scheduled = set() + self.queue = Queue.Queue() self.processUpdates() def processUpdates(self): - updateRequests = self.updateRequests - cv = self.cv - + queue = self.queue while True: - cv.acquire() - - while len(updateRequests) == 0: - cv.wait() - # Grab our data and rerelease the lock - callback, requests = self.updateRequests.popleft() - self.scheduled.clear() - cv.release() + callback, requests = queue.get() # Grab prices, this is the time-consuming part if len(requests) > 0: eos.types.Price.fetchPrices(*requests) wx.CallAfter(callback) - + queue.task_done() def trigger(self, prices, callbacks): - self.cv.acquire() - self.updateRequests.append((callbacks, prices)) - self.scheduled.update(prices) - self.cv.notify() - self.cv.release() - - def isScheduled(self, price): - self.cv.acquire() - scheduled = price in self.scheduled - self.cv.release() - return scheduled + self.queue.put((callbacks, prices)) class SearchWorkerThread(threading.Thread): def run(self): @@ -258,7 +238,6 @@ class Market(): price = eos.types.Price(typeID) eos.db.saveddata_session.add(price) - requests.append(price) self.priceCache[typeID] = price requests.append(price)