(self)
| 242 | pyfalog.debug("Initialize PriceWorkerThread.") |
| 243 | |
| 244 | def run(self): |
| 245 | queue = self.queue |
| 246 | while True: |
| 247 | if not self.running: |
| 248 | break |
| 249 | # Grab our data |
| 250 | callback, requests, fetchTimeout, validityOverride = queue.get() |
| 251 | |
| 252 | # Grab prices, this is the time-consuming part |
| 253 | if len(requests) > 0: |
| 254 | Price.fetchPrices(requests, fetchTimeout, validityOverride) |
| 255 | |
| 256 | wx.CallAfter(callback) |
| 257 | queue.task_done() |
| 258 | |
| 259 | # After we fetch prices, go through the list of waiting items and call their callbacks |
| 260 | for price in requests: |
| 261 | callbacks = self.wait.pop(price.typeID, None) |
| 262 | if callbacks: |
| 263 | for callback in callbacks: |
| 264 | wx.CallAfter(callback) |
| 265 | |
| 266 | def trigger(self, prices, callbacks, fetchTimeout, validityOverride): |
| 267 | self.queue.put((callbacks, prices, fetchTimeout, validityOverride)) |
no test coverage detected