Exemplo n.º 1
0
 def _createQueueServer(self):
     #    Create the QueueServer by using os.system or Subprocess.
     #    Create a reply-to Ping server:
     self.rqs= QueueServer(host=self.host,
                           port=self.portReplyTo,
                           target=self.target,
                           marshaller=self.m,
                           hunt=True,
                           quiet=self.quiet,
                           maxClients=self.maxClients,
                           recvChunkSize=self.recvChunkSize,
                           readTimeout=self.readTimeout,
                           )
     self.rqs.start().waitUntilRunning()
     #    Now create the subprocess server:
     desiredPort = 50001
     linkage = Linkage.create(Pinger)
     self.qs = SubprocessQueueServer(handlerClazz=Linkage.create(QueueServerHandler),
                                     desiredPort=desiredPort,
                                     linkage=linkage,
                                     quiet=self.quiet)
     self.details = self.qs.details()
Exemplo n.º 2
0
 def setUp(self):
     self.logger = self._getLogger()
     self.quiet=True
     self.random = Random()
     self.timerTerminate = 0
     self._timers = []
     self.namespaces = []
     self.dummyQueue = Queue()
     self.iface = PyRQIface(ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
     self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
     desiredPort = "19001"
     self.r = SubprocessQueueServer(
                                    desiredPort=desiredPort,
                                    handlerClazz=Linkage.create(TimeoutMockHandler),
                                    quiet=self.quiet,
        )
     PyRQIface.setGlobalPYRQ(self.r.details())
Exemplo n.º 3
0
    def setUp(self):
        self.quiet=True
        self.random = Random()
        self._timers = []
        self.namespaces = []
        self.iface = PyRQIface(quiet=self.quiet, ref="test")
        self.dummyQueue = Queue()
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(MockHandler),
                                       quiet=self.quiet
#           includePydevd="/home/francis/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc"
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
        self.r.start().waitUntilRunning()
        pass
Exemplo n.º 4
0
def _loadHost(options, handlerClazz, **kwargs):
    servicesClazzpath = options.servicesClazzpath
    servicesClazz = options.servicesClazz
    quiet = options.quiet
    if (servicesClazzpath!=None) and (len(servicesClazzpath)>0) and (servicesClazz!=None) and (len(servicesClazz)>0):
        services = _importModule(options.servicesClazzpath, options.servicesClazz)
        from PyRQ import PyRQTimeUtils
        PyRQTimeUtils.set_getTime(services.getSystemUptimeInteger)
        PyRQTimeUtils.set_delayTime(services.timeSleep)
        b = PyRQTimeUtils.getTime()
        if not quiet: sys.stderr.write("subprocess getTime()...%(T)s\r\n"%{"T":b})
    if options.handlerClazz!=None:
        handlerClazz = _getClass(options.handlerClazz)
        hC = Linkage.create(handlerClazz)
    else:
        msg = "No HandlerClazz specified!!!"
        sys.stderr.write(msg)
        raise Exception(msg)
#        hC = Linkage.create(RRQHandler)
#        handlerClazz = _getClass(".".join([hC.clazzpath(), hC.clazz()]))
    if not quiet: sys.stderr.write("BootQueueServer::handlerClazz... %(H)s  .  %(P)s\r\n"%{"H":hC.clazzpath(), "P":hC.clazz()})
    from multiprocessing.queues import Queue
    mt = options.marshallerType
    mt = int(mt)
    target=Queue()
    kwargs["maxClients"] = options.maxClients
    kwargs["quiet"] = quiet
    kwargs["recvChunkSize"] = int(options.socketRecvChunkSize)
    kwargs["readTimeout"] = int(options.socketReadTimeout)
    kwargs["loggerModule"] = _loadLoggingModule(options.loggingModule)
    qs = QueueServer(host=options.host,
                     port=options.port,
                     marshaller=MarshallerFactory.get(mt, quiet=quiet),
                     target=target,
                     handlerClazz=handlerClazz,
                     **kwargs)
    qs.start().waitUntilRunning()
    if options.ackHost and options.ackPort:
        #    Send the ack back!
        if not quiet: sys.stderr.write("BootQueueServer::load...[0.1]: %(H)s:%(P)s[1]\r\n"%{"H":options.ackHost, "P":options.ackPort})
        from PyRQ.Core.QueueWriter.QueueWriter import QueueWriter
#        import pydevd
#        pydevd.settrace(stdoutToServer = True, stderrToServer = True)
        qw = QueueWriter(target=QueueServerDetails(options.ackHost, options.ackPort),
                        marshaller=MarshallerFactory.get(mt, quiet=quiet),
                        autoConnect=True,
                        sockTimeout=10,
                        quiet=quiet
                        )
        if not quiet: sys.stderr.write("BootQueueServer::load...[1.0]\r\n")
        qw.start()
        details = qs.details()
        if not quiet: sys.stderr.write("BootQueueServer::load...[1.2]: %(D)s\r\n"%{"D":details})
        qw.put(details)
        if not quiet: sys.stderr.write("BootQueueServer::load...[1.2]\r\n")
    #    Now we have a queue which we can use to receive messages on:    'target'.
    importedModule = None
    if options.clazzpath!=None and options.clazz!=None:
        if not quiet: sys.stderr.write("BootQueueServer::load...Launching %(P)s.%(C)s with target queue: %(Q)s\r\n"%{"P":options.clazzpath, "C":options.clazz, "Q":target})
        try:
            importedModule = _importModule(options.clazzpath, options.clazz)(qs)
        except Exception, _e:
            sys.stderr.write("Error Launching %(P)s.%(C)s with target queue: %(Q)s\r\n%(T)s\r\n"%{"P":options.clazzpath, "C":options.clazz, "Q":target, "T":traceback.format_exc()})
Exemplo n.º 5
0
 def test(self):
     result = Linkage.create(Classicname)
     assert isinstance(result, Linkage)
     assert result.clazz()=="Classicname"
     assert result.clazzpath()=="test.testArtefacts.ModuleName"