Exemplo n.º 1
0
 def run(self, block=True):
     """Sets up everything and starts the event loops."""
     # If we are in a multiprocessing loop then check that cothread has not
     # been inherited from the forked mainprocess. If it has then we can't
     # use cothread as we will share the same scheduler!
     if type(multiprocessing.current_process()) == type(self):
         # We are in a multiprocessing child process
         assert "cothread" not in sys.modules, \
             "Cothread has already been imported, this will not work!"
     self.loop_run()
     server_strings = []
     for string in self.server_strings:
         ss = ServerSocket.make_socket(string, self.router.inq)
         assert ss is not None, "Can't make socket for {}".format(string)
         self._server_socks[string] = ss
         self.add_loop(ss)
         server_strings.append(ss.name)
     self.server_strings = server_strings
     # Create a client to directory service
     if self.ds_string is not None:
         self.ds = self.get_device(self.ds_name, [self.ds_string])
         # Make a timer to keep checking ds has our devices
         self.add_loop(TimerLoop(self.name + ".dsupdate",
                                 self.register_devices, 10))
     self.quitsig = self.cothread.Pulse()
     if block:
         self.quitsig.Wait()
Exemplo n.º 2
0
 def setUp(self):
     self.inq = cothread.EventQueue()
     self.ss = ServerSocket.make_socket("dzmq://ipc://frfess.ipc", self.inq)        
     self.ss.loop_run()
 def setUp(self):
     self.cs = ClientSocket.make_socket("zmq://ipc://tmp/frfes.ipc")
     self.cs.loop_run()
     self.ss = ServerSocket.make_socket("zmq://ipc:///tmp/frfess.ipc", None)
     self.ss.open(self.ss.address)