ATLAS Offline Software
Loading...
Searching...
No Matches
python.MpUtils.SubProcessIterator Class Reference
Inheritance diagram for python.MpUtils.SubProcessIterator:
Collaboration diagram for python.MpUtils.SubProcessIterator:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

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

Static Public Member Functions

 work (iterator, master, eoi)

Public Attributes

 client
 master = Pipe()
 end_of_input = eoi
 process = Process(target=self.work, args=pargs)
bool started = False
 next = self._empty

Protected Member Functions

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

Detailed Description

Instances of this class process iterators in separate processes.

Definition at line 27 of file MpUtils.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

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__()

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()

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

Definition at line 66 of file MpUtils.py.

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

◆ _start()

python.MpUtils.SubProcessIterator._start ( self)
protected

Definition at line 42 of file MpUtils.py.

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

◆ next()

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()

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

◆ client

python.MpUtils.SubProcessIterator.client

Definition at line 36 of file MpUtils.py.

◆ end_of_input

python.MpUtils.SubProcessIterator.end_of_input = eoi

Definition at line 37 of file MpUtils.py.

◆ master

python.MpUtils.SubProcessIterator.master = Pipe()

Definition at line 36 of file MpUtils.py.

◆ next

python.MpUtils.SubProcessIterator.next = self._empty

Definition at line 63 of file MpUtils.py.

◆ process

python.MpUtils.SubProcessIterator.process = Process(target=self.work, args=pargs)

Definition at line 39 of file MpUtils.py.

◆ started

bool python.MpUtils.SubProcessIterator.started = False

Definition at line 40 of file MpUtils.py.


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