ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
python.MpUtils.SubProcessIterator Class Reference
Inheritance diagram for python.MpUtils.SubProcessIterator:
Collaboration diagram for python.MpUtils.SubProcessIterator:

Public Member Functions

def __init__ (self, itertask, eoi='__eoi__')
 
def __iter__ (self)
 
def next (self)
 

Static Public Member Functions

def work (iterator, master, eoi)
 

Public Attributes

 master
 
 end_of_input
 
 process
 
 started
 
 next
 

Private Member Functions

def _start (self)
 
def _empty (self, *args, **params)
 

Detailed Description

Instances of this class process iterators in separate processes.

Definition at line 27 of file MpUtils.py.

Constructor & Destructor Documentation

◆ __init__()

def python.MpUtils.SubProcessIterator.__init__ (   self,
  itertask,
  eoi = '__eoi__' 
)
Create a new subprocess iterator.

itertask : some iterable task to execute in a subprocess
eoi : an end-of-iteration marker - returned from the subprocess
      to signal that iteration is complete.

Definition at line 29 of file MpUtils.py.

29  def __init__(self, itertask, eoi='__eoi__'):
30  """Create a new subprocess iterator.
31 
32  itertask : some iterable task to execute in a subprocess
33  eoi : an end-of-iteration marker - returned from the subprocess
34  to signal that iteration is complete.
35  """
36  self.client, self.master = Pipe()
37  self.end_of_input = eoi
38  pargs = [itertask, self.master, eoi]
39  self.process = Process(target=self.work, args=pargs)
40  self.started = False
41 

Member Function Documentation

◆ __iter__()

def python.MpUtils.SubProcessIterator.__iter__ (   self)

Definition at line 53 of file MpUtils.py.

53  def __iter__(self):
54  if not self.started:
55  self._start()
56  return self
57 

◆ _empty()

def python.MpUtils.SubProcessIterator._empty (   self,
args,
**  params 
)
private

Definition at line 66 of file MpUtils.py.

66  def _empty(self, *args, **params):
67  raise StopIteration
68 

◆ _start()

def python.MpUtils.SubProcessIterator._start (   self)
private

Definition at line 42 of file MpUtils.py.

42  def _start(self):
43  self.started = True
44  self.process.start()
45 

◆ next()

def python.MpUtils.SubProcessIterator.next (   self)

Definition at line 58 of file MpUtils.py.

58  def next(self):
59  item = self.client.recv()
60  if item != self.end_of_input:
61  return item
62  else:
63  self.next = self._empty
64  raise StopIteration
65 

◆ work()

def python.MpUtils.SubProcessIterator.work (   iterator,
  master,
  eoi 
)
static
The actual callable that is executed in the subprocess.

Definition at line 47 of file MpUtils.py.

47  def work(iterator, master, eoi):
48  """The actual callable that is executed in the subprocess."""
49  for chunk in iterator:
50  master.send(chunk)
51  master.send(eoi)
52 

Member Data Documentation

◆ end_of_input

python.MpUtils.SubProcessIterator.end_of_input

Definition at line 37 of file MpUtils.py.

◆ master

python.MpUtils.SubProcessIterator.master

Definition at line 36 of file MpUtils.py.

◆ next

python.MpUtils.SubProcessIterator.next

Definition at line 63 of file MpUtils.py.

◆ process

python.MpUtils.SubProcessIterator.process

Definition at line 39 of file MpUtils.py.

◆ started

python.MpUtils.SubProcessIterator.started

Definition at line 40 of file MpUtils.py.


The documentation for this class was generated from the following file:
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
python.Bindings.__iter__
__iter__
Definition: Control/AthenaPython/python/Bindings.py:791
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18