コード例 #1
0
 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)
コード例 #2
0
    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
コード例 #3
0
    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)
コード例 #4
0
ファイル: xmlrpcserver.py プロジェクト: gansaihua/pyalgotrade
    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
コード例 #5
0
ファイル: worker.py プロジェクト: gansaihua/pyalgotrade
 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)