The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiMP.GMPBase.EventCommunicator Class Reference

Public Member Functions

 __init__ (self, GMPComponent, qin, qout)
 send (self, item)
 receive (self, timeout=None)
 finalize (self)
 statistics (self)

Public Attributes

 log = self._gmpc.log
int maxsize = 50
 qin = qin
 qout = qout
bool allsent = False
bool allrecv = False
int nSent = 0
int nRecv = 0
int sizeSent = 0
int sizeRecv = 0
int qinTime = 0
int qoutTime = 0

Protected Attributes

 _gmpc = GMPComponent

Detailed Description

Definition at line 264 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiMP.GMPBase.EventCommunicator.__init__ ( self,
GMPComponent,
qin,
qout )

Definition at line 268 of file GMPBase.py.

268 def __init__(self, GMPComponent, qin, qout):
269 self._gmpc = GMPComponent
270 self.log = self._gmpc.log
271 # maximum capacity of Queues
272 self.maxsize = 50
273 # central variables : Queues
274 self.qin = qin
275 self.qout = qout
276
277 # flags
278 self.allsent = False
279 self.allrecv = False
280
281 # statistics storage
282 self.nSent = 0 # counter : items sent
283 self.nRecv = 0 # counter : items received
284 self.sizeSent = 0 # measure : size of events sent ( tbuf.Length() )
285 self.sizeRecv = 0 # measure : size of events in ( tbuf.Length() )
286 self.qinTime = 0 # time : receiving from self.qin
287 self.qoutTime = 0 # time : sending on qout
288

Member Function Documentation

◆ finalize()

GaudiMP.GMPBase.EventCommunicator.finalize ( self)

Definition at line 325 of file GMPBase.py.

325 def finalize(self):
326 self.log.info(
327 f"Finalize Event Communicator : {self._gmpc} {self._gmpc.nodeType}"
328 )
329 # Reader sends one flag for each worker
330 # Workers send one flag each
331 # Writer sends nothing (it's at the end of the chain)
332 if self._gmpc.nodeType == "Reader":
333 downstream = self._gmpc.nWorkers
334 elif self._gmpc.nodeType == "Writer":
335 downstream = 0
336 elif self._gmpc.nodeType == "Worker":
337 downstream = 1
338
339 for i in range(downstream):
340 self.qout.put("FINISHED")
341 if self._gmpc.nodeType != "Writer":
342 self.qout.join()
343 # Now some reporting...
344 self.statistics()
345

◆ receive()

GaudiMP.GMPBase.EventCommunicator.receive ( self,
timeout = None )

Definition at line 304 of file GMPBase.py.

304 def receive(self, timeout=None):
305 # Receive items from self.qin
306 startWait = time.time()
307 try:
308 itemIn = self.qin.get(timeout=timeout)
309 except Empty:
310 return None
311 self.qinTime += time.time() - startWait
312 self.nRecv += 1
313 if itemIn.__class__.__name__ == "tuple":
314 self.sizeRecv += itemIn[1].Length()
315 else:
316 self.nRecv -= 1
317 try:
318 self.qin.task_done()
319 except Exception:
320 self._gmpc.log.warning(
321 f"TASK_DONE called too often by : {self._gmpc.nodeType}"
322 )
323 return itemIn
324

◆ send()

GaudiMP.GMPBase.EventCommunicator.send ( self,
item )

Definition at line 289 of file GMPBase.py.

289 def send(self, item):
290 # This class manages the sending of a TBufferFile Event to a Queue
291 # The actual item to be sent is a tuple : ( evtNumber, TBufferFile )
292 assert item.__class__.__name__ == "tuple"
293 startTransmission = time.time()
294 self.qout.put(item)
295 # allow the background thread to feed the Queue; not 100% guaranteed to
296 # finish before next line
297 while self.qout._buffer:
298 time.sleep(NAP)
299 self.qoutTime += time.time() - startTransmission
300 self.sizeSent += item[1].Length()
301 self.nSent += 1
302 return SUCCESS
303

◆ statistics()

GaudiMP.GMPBase.EventCommunicator.statistics ( self)

Definition at line 346 of file GMPBase.py.

346 def statistics(self):
347 self.log.name = f"{self._gmpc.nodeType}-{self._gmpc.nodeID} Audit "
348 self.log.info(f"Items Sent : {self.nSent}")
349 self.log.info(f"Items Received : {self.nRecv}")
350 self.log.info(f"Data Sent : {self.sizeSent}")
351 self.log.info(f"Data Received : {self.sizeRecv}")
352 self.log.info(f"Q-out Time : {self.qoutTime:5.2f}")
353 self.log.info(f"Q-in Time : {self.qinTime:5.2f}")
354
355
356# =============================================================================
357
358

Member Data Documentation

◆ _gmpc

GaudiMP.GMPBase.EventCommunicator._gmpc = GMPComponent
protected

Definition at line 269 of file GMPBase.py.

◆ allrecv

bool GaudiMP.GMPBase.EventCommunicator.allrecv = False

Definition at line 279 of file GMPBase.py.

◆ allsent

bool GaudiMP.GMPBase.EventCommunicator.allsent = False

Definition at line 278 of file GMPBase.py.

◆ log

GaudiMP.GMPBase.EventCommunicator.log = self._gmpc.log

Definition at line 270 of file GMPBase.py.

◆ maxsize

int GaudiMP.GMPBase.EventCommunicator.maxsize = 50

Definition at line 272 of file GMPBase.py.

◆ nRecv

int GaudiMP.GMPBase.EventCommunicator.nRecv = 0

Definition at line 283 of file GMPBase.py.

◆ nSent

int GaudiMP.GMPBase.EventCommunicator.nSent = 0

Definition at line 282 of file GMPBase.py.

◆ qin

GaudiMP.GMPBase.EventCommunicator.qin = qin

Definition at line 274 of file GMPBase.py.

◆ qinTime

int GaudiMP.GMPBase.EventCommunicator.qinTime = 0

Definition at line 286 of file GMPBase.py.

◆ qout

GaudiMP.GMPBase.EventCommunicator.qout = qout

Definition at line 275 of file GMPBase.py.

◆ qoutTime

int GaudiMP.GMPBase.EventCommunicator.qoutTime = 0

Definition at line 287 of file GMPBase.py.

◆ sizeRecv

int GaudiMP.GMPBase.EventCommunicator.sizeRecv = 0

Definition at line 285 of file GMPBase.py.

◆ sizeSent

int GaudiMP.GMPBase.EventCommunicator.sizeSent = 0

Definition at line 284 of file GMPBase.py.


The documentation for this class was generated from the following file: