Esempio n. 1
0
 def sendHistograms(self):
             msg = DXMessage("hist")
             nhist = 0
             for hid, hacc in self.HAccumulators.items():
                 if hacc.NFills:
                     #print ("sendHistograms: counts=", hacc.H.Counts)
                     msg.append("h:"+hid, hacc.dump())
                     nhist += 1
             if nhist:
                 self.DXSock.send(msg)
Esempio n. 2
0
 def endOfFrame(self, nevents):
     #self.log("end of frame")
     self.DXSock.send(DXMessage("events", events_delta=nevents))
     t = time.time()
     if self.NFills:
         self.LastFlush = t
         msg = DXMessage("hist")
         for hid, hb in self.HCollectors.items():
             msg.append("h:"+hid, hb.dump())
             #print "counts:", counts
         self.DXSock.send(msg)
         self.NFills = 0
Esempio n. 3
0
 def toDXMsg(self):
     msg = DXMessage("worker_task", jid=self.JID,
         worker_module_name = self.WorkerModuleName, 
         bulk_data_name = self.BulkDataName,
         dataset_name = self.DatasetName,
         use_data_cache = "yes" if self.UseDataCache else "no",
         data_server_url = self.DataServerURL,
         data_mod_url = self.DataModURL,
         data_mod_token = self.DataModToken)
     msg.append(
         histograms = json.dumps(self.HDescriptors),
         user_params = self.UserParams           # this is encoded by the job server, do not decode it yet
     )
     return msg
Esempio n. 4
0
    def updateReceived(self, wid, hists, streams, nevents_delta):

        self.TotalEvents += nevents_delta
        client_disconnected = False

        if hists:
            msg = DXMessage("histograms",
                            total_events=self.TotalEvents,
                            wid=wid)
            for k, v in hists.items():
                msg[k] = v
            try:
                self.DataExchange.send(msg)
            except:
                self.log("Error sending message to the client:\n%s" %
                         (traceback.format_exc(), ))
                client_disconnected = True

        if streams:
            for k, data in streams.items():
                msg = DXMessage("stream",
                                name=k,
                                format="pickle",
                                total_events=self.TotalEvents,
                                wid=wid)
                msg.append(
                    data=data
                )  # this is still pickled data because the WorkerInterface does not unpickle
                try:
                    self.DataExchange.send(msg)
                except:
                    self.log("Error sending message to the client:\n%s" %
                             (traceback.format_exc(), ))
                    client_disconnected = True

        if not streams and not hists:
            #print "sending empty(%d)" % (self.TotalEvents,)
            msg = DXMessage("empty", total_events=self.TotalEvents, wid=wid)
            try:
                self.DataExchange.send(msg)
            except:
                self.log("Error sending message to the client:\n%s" %
                         (traceback.format_exc(), ))
                client_disconnected = True
        if client_disconnected:
            self.log(
                "Client disconnected (because of the communication error). Aborting"
            )
            self.Contract.abort()