Example #1
0
    def run(self):
        """Creates one C2S and one S2S server and runs them.
        Also initializes the threadpools for each server.
        """
        # imports happen here, because otherwise we could create a cycle
        from pjs.server import C2SServer, S2SServer
        self._c2s = C2SServer(self.hostname, self.c2sport, self)
        self.servers.append(self._c2s)

        self._s2s = S2SServer(self.hostname, self.s2sport, self)
        self.servers.append(self._s2s)

        from pjs.connection import LocalTriggerConnection

        # see connection.LocalTriggerConnection.__doc__
        self.triggerConn = LocalTriggerConnection(self.hostname, self.c2sport)

        def notifyFunc():
            """Function that gets executed when a job in a threadpool
            completes.
            """
            self.triggerConn.send(' ')

        self._c2s.createThreadpool(5, notifyFunc)
        self._s2s.createThreadpool(5, notifyFunc)
Example #2
0
class PJSLauncher:
    """The one and only instance of the server. This controls all other
    components.
    """
    def __init__(self):
        """Initializes the server data"""
        self.servers = []

        self.c2sport = 5222
        self.s2sport = 5269

        self.hostname = 'localhost'

        self._c2s, self._s2s = (None, None)

    def run(self):
        """Creates one C2S and one S2S server and runs them.
        Also initializes the threadpools for each server.
        """
        # imports happen here, because otherwise we could create a cycle
        from pjs.server import C2SServer, S2SServer
        self._c2s = C2SServer(self.hostname, self.c2sport, self)
        self.servers.append(self._c2s)

        self._s2s = S2SServer(self.hostname, self.s2sport, self)
        self.servers.append(self._s2s)

        from pjs.connection import LocalTriggerConnection

        # see connection.LocalTriggerConnection.__doc__
        self.triggerConn = LocalTriggerConnection(self.hostname, self.c2sport)

        def notifyFunc():
            """Function that gets executed when a job in a threadpool
            completes.
            """
            self.triggerConn.send(' ')

        self._c2s.createThreadpool(5, notifyFunc)
        self._s2s.createThreadpool(5, notifyFunc)

    def stop(self):
        """Shuts down the servers"""
        self.triggerConn.handle_close()
        self._c2s.handle_close(True)
        self._s2s.handle_close(True)

    def getC2SServer(self):
        """Returns the C2S server"""
        return self._c2s

    def getS2SServer(self):
        """Returns the S2S server"""
        return self._s2s
Example #3
0
class PJSLauncher:
    """The one and only instance of the server. This controls all other
    components.
    """
    def __init__(self):
        """Initializes the server data"""
        self.servers = []

        self.c2sport = 5222
        self.s2sport = 5269

        self.hostname = 'localhost'

        self._c2s, self._s2s = (None, None)

    def run(self):
        """Creates one C2S and one S2S server and runs them.
        Also initializes the threadpools for each server.
        """
        # imports happen here, because otherwise we could create a cycle
        from pjs.server import C2SServer, S2SServer
        self._c2s = C2SServer(self.hostname, self.c2sport, self)
        self.servers.append(self._c2s)

        self._s2s = S2SServer(self.hostname, self.s2sport, self)
        self.servers.append(self._s2s)

        from pjs.connection import LocalTriggerConnection

        # see connection.LocalTriggerConnection.__doc__
        self.triggerConn = LocalTriggerConnection(self.hostname, self.c2sport)

        def notifyFunc():
            """Function that gets executed when a job in a threadpool
            completes.
            """
            self.triggerConn.send(' ')

        self._c2s.createThreadpool(5, notifyFunc)
        self._s2s.createThreadpool(5, notifyFunc)

    def stop(self):
        """Shuts down the servers"""
        self.triggerConn.handle_close()
        self._c2s.handle_close(True)
        self._s2s.handle_close(True)

    def getC2SServer(self):
        """Returns the C2S server"""
        return self._c2s
    def getS2SServer(self):
        """Returns the S2S server"""
        return self._s2s
Example #4
0
    def run(self):
        """Creates one C2S and one S2S server and runs them.
        Also initializes the threadpools for each server.
        """
        # imports happen here, because otherwise we could create a cycle
        from pjs.server import C2SServer, S2SServer
        self._c2s = C2SServer(self.hostname, self.c2sport, self)
        self.servers.append(self._c2s)

        self._s2s = S2SServer(self.hostname, self.s2sport, self)
        self.servers.append(self._s2s)

        from pjs.connection import LocalTriggerConnection

        # see connection.LocalTriggerConnection.__doc__
        self.triggerConn = LocalTriggerConnection(self.hostname, self.c2sport)

        def notifyFunc():
            """Function that gets executed when a job in a threadpool
            completes.
            """
            self.triggerConn.send(' ')

        self._c2s.createThreadpool(5, notifyFunc)
        self._s2s.createThreadpool(5, notifyFunc)