def pushJobResults(self, jobId, result, parameters): jobId = serialization.dumps(jobId) result = serialization.dumps(result) parameters = serialization.dumps(parameters) workerName = serialization.dumps(self.__workerName) retry_on_network_error(self.__server.pushJobResults, jobId, result, parameters, workerName)
def serve(self): assert len(self.__barFeed.getAllFrequencies()) == 1 try: # Initialize instruments, bars and parameters. logger.info("Loading bars") loadedBars = [] for dateTime, bars, freq in self.__barFeed: loadedBars.append(bars) instruments = self.__barFeed.getRegisteredInstruments() self.__instrumentsAndBars = serialization.dumps( (instruments, loadedBars)) self.__barsFreq = self.__barFeed.getAllFrequencies()[0] if self.__autoStopThread: self.__autoStopThread.start() logger.info("Started serving") self.__startedServingEvent.set() self.serve_forever() logger.info("Finished serving") if self.__autoStopThread: self.__autoStopThread.join() finally: self.__forcedStop = True
def getNextJob(self): ret = None with self.__lock: # Get the next set of parameters. params = [p.args for p in self.__paramSource.getNext(self.__batchSize)] # Map the active job if len(params): ret = Job(params) self.__activeJobs[ret.getId()] = ret return serialization.dumps(ret)
def serve(self): try: # Initialize instruments, bars and parameters. logger.info("Loading bars") loadedBars = [] for dateTime, bars in self.__barFeed: loadedBars.append(bars) instruments = self.__barFeed.getRegisteredInstruments() self.__instrumentsAndBars = serialization.dumps((instruments, loadedBars)) self.__barsFreq = self.__barFeed.getFrequency() if self.__autoStopThread: self.__autoStopThread.start() logger.info("Started serving") self.__startedServingEvent.set() self.serve_forever() logger.info("Finished serving") if self.__autoStopThread: self.__autoStopThread.join() finally: self.__forcedStop = True