diff options
| author | Stan Seibert <stan@mtrr.org> | 2012-02-17 14:22:05 -0500 | 
|---|---|---|
| committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:38 -0700 | 
| commit | 2e8d535456730aed81d47af2d78ef5775810151b (patch) | |
| tree | 16f7a8f3df524d27ada83241b1b4a7bdc20f6ee6 | |
| parent | aa14bc9f0947a77781c1234c38f422f18b2fe154 (diff) | |
| download | chroma-2e8d535456730aed81d47af2d78ef5775810151b.tar.gz chroma-2e8d535456730aed81d47af2d78ef5775810151b.tar.bz2 chroma-2e8d535456730aed81d47af2d78ef5775810151b.zip | |
Improve startup time in simulation by letting GEANT4 processes initialize in background.
| -rw-r--r-- | chroma/generator/photon.py | 16 | 
1 files changed, 10 insertions, 6 deletions
| diff --git a/chroma/generator/photon.py b/chroma/generator/photon.py index 39e8cf4..43c3a49 100644 --- a/chroma/generator/photon.py +++ b/chroma/generator/photon.py @@ -81,13 +81,17 @@ class G4ParallelGenerator(object):          self.photon_socket = self.zmq_context.socket(zmq.PULL)          self.photon_socket.bind(self.photon_address) -        # Verify everyone is running and connected to avoid -        # sending all the events to one client. -        for i in xrange(nprocesses): -            msg = self.photon_socket.recv() -            assert msg == 'READY' - +        self.processes_initialized = False +              def generate_events(self, vertex_iterator): +        if not self.processes_initialized: +            # Verify everyone is running and connected to avoid +            # sending all the events to one client. +            for i in xrange(len(self.processes)): +                msg = self.photon_socket.recv() +                assert msg == 'READY' +            self.processes_initialized = True +          # Doing this to avoid a deadlock caused by putting to one queue          # while getting from another.          vertex_list = list(vertex_iterator) | 
