コード例 #1
0
def startNodeThread(nodeID, nodeIp, nodeport):
    '''
    启动主服务线程
    '''
    dataNode = classpartial(DataNode, nodeID, nodeIp, nodeport)
    t = ThreadedServer(dataNode, hostname=nodeIp, port=nodeport)
    NodeStatus[nodeID].append(t)
    t.start()
コード例 #2
0
ファイル: events.py プロジェクト: Ashleybishop37/CIDM6325
    def __init__(self, app, options):
        self.state = EventsState()
        self.options = options
        self.app = app
        self.server = None

        self.service = classpartial(CeleryStateService, self.state)
        self.client = RpcClient(self.service)
コード例 #3
0
def rcmd_start(alias, port, cmd):
    from rpyc.utils.server import ThreadedServer
    if rpyc.version.version[0] >= 4:
        from rpyc.utils.helpers import classpartial
        service = classpartial(RCMDService, alias=alias, cmd=cmd)
        log("Stating threaded service named {} on port {} with command {}".format(alias, port, cmd))
        ThreadedServer(service, port=port).start()
    else:
        ThreadedServer(RCMDService, port=port).start()
コード例 #4
0
ファイル: server.py プロジェクト: zixzeus/schedule-system
def get_server(listen_config, scheduler, SchedulerServiceClass=None):
    # 额外构造函数参数
    ser_args = ['test args']
    ser_kwargs = {}
    # 传递Service构造函数参数
    SSC = SchedulerServiceClass if SchedulerServiceClass is not None else SchedulerService
    service = classpartial(SSC, scheduler, *ser_args, **ser_kwargs)
    # 允许属性访问
    protocol_config = {'allow_public_attrs': True}
    # 实例化RPYC服务器
    server = ThreadedServer(service,  protocol_config=protocol_config, **listen_config)
    return server
コード例 #5
0
ファイル: Service.py プロジェクト: kurzacz/winservicewatch
    def run(self):
        """
        Starts and keep running ServiceGate on dedicated thread

        Rpyc package offers builders for services, which is blocking.
            For that reason, it must run on another thread, otherwise it will block your app. See more:
            https://rpyc.readthedocs.io/en/latest/api/utils_server.html#rpyc.utils.server.Server.start
        """
        logging.getLogger().debug('Starting thread for ServiceGate')
        service = classpartial(self._gateClass, self._observedService)
        t = ThreadedServer(service, port=self._port)
        t.start()
        logging.getLogger().debug('Thread for ServiceGate finished running')
コード例 #6
0
def main():
    """main
    """
    multiprocessing.set_start_method('spawn', force=True)
    que = multiprocessing.Queue()

    n_process = int(os.environ.get('NUM_TABLE_DETECTORS', '1'))
    for i in range(n_process):
        p = multiprocessing.Process(target=worker, args=(que,), daemon=True)
        p.start()

    service = classpartial(TableDetector, que=que)
    t = rpyc.utils.server.ThreadedServer(service, port=18861)
    t.start()
コード例 #7
0
ファイル: rpyc_client.py プロジェクト: Pro1d/WelcomeHome
    def __init__(self, name, callback=None, address="localhost", port=18812):
        self._name = name
        conn = None
        while conn is None:
            try:
                service = classpartial(MessagingClientService, name, callback)
                conn = rpyc.connect(address, port, service=service)
                self._conn = conn
            except Exception as e:
                print(e, file=sys.stderr)
                print("Retry in 5sec...")
                time.sleep(5)

        rpyc.BgServingThread(self._conn)
コード例 #8
0
ファイル: Client.py プロジェクト: kurzacz/winservicewatch
 def startPort(self):
     portConstructor = classpartial(self.Port, self._app)
     self._portServer = ThreadedServer(portConstructor, port=18870)
     self._portServer.start()
コード例 #9
0
        table.rows.header = ["S" + str(i) for i in range(1, len(result) + 1)]
        table.columns.header = [
            description[0]
            for description in self.sqlite_handler.cursor.description
        ]

        return table

    def exposed_quit(self) -> None:
        exit()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='TCP Server Program')
    parser.add_argument('-p',
                        metavar='PORT',
                        type=int,
                        default=1060,
                        help='TCP port (default 1060)')
    parser.add_argument('-d',
                        metavar='DATABASE',
                        type=str,
                        default='data.db',
                        help='Database (default data.db)')

    args = parser.parse_args()
    print(f'Server running on port {args.p} using {args.d}')
    service = classpartial(SqliteHandlerService, args.d)
    server = ThreadedServer(service, port=args.p)
    server.start()
コード例 #10
0
ファイル: cio_rpc_server.py プロジェクト: cwipy/libauto
        version = version_reader.version()
        #get_h().dispose_component_interface(version_reader)   # <-- VersionInfo is always pre-enabled, so don't disable it.
        log.info("Controller version: {}".format(version))
    except Exception as e:
        version = None
        log.error("Unable to get controller version: {}".format(e))
        # Allow error to pass, so that the server can start below.
        # The server will report this error to clients.

    global_lock = Semaphore(value=1)

    always_enabled_components = []
    if version is not None:
        if version < (1, 1):
            always_enabled_components.append('CarMotors')

    component_manager = ComponentManager(global_lock,
                                         always_enabled_components)

    ControllerService = classpartial(ControllerService, component_manager,
                                     global_lock, version)

    rpc_server = GeventServer(ControllerService, port=18861)

    log.info("RUNNING!")

    gevent.joinall([
        gevent.spawn(rpc_server.start),
        #gevent.spawn(component_manager.callback_thread),
    ])
コード例 #11
0
ファイル: console_ui.py プロジェクト: cwipy/libauto
            draw_all()

    def exposed_set_battery_percent(self, pct):
        """
        `pct` should be an integer in [0, 100].
        """
        with self.lock:
            if not isinstance(pct, int) or not (0 <= pct <= 100):
                raise Exception("Invalid battery percent")
            pct = "{}%".format(pct)
            global battery_sprite
            battery_sprite = header_font.render(pct, True, HEADER_TXT_COLOR)
            draw_all()


from rpyc.utils.server import GeventServer
from rpyc.utils.helpers import classpartial

global_lock = Semaphore(value=1)

ConsoleService = classpartial(ConsoleService, global_lock)

rpc_server = GeventServer(ConsoleService, port=18863)

log.info("RUNNING!")

gevent.joinall([
    gevent.spawn(rpc_server.start),
])

コード例 #12
0
ファイル: server.py プロジェクト: kaori02/progjar
            description[0]
            for description in self.sqlite_service.cursor.description
        ]

        return table

    def exposed_quit(self) -> None:
        exit()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='TCP Server Program')
    parser.add_argument('-p',
                        metavar='PORT',
                        type=int,
                        default=1060,
                        help='TCP port (default 1060)')
    parser.add_argument('-d',
                        metavar='DATABASE',
                        type=str,
                        default='data.db',
                        help='Database (default data.db)')

    args = parser.parse_args()
    print(f'Server running on port {args.p} using {args.d}')

    service = classpartial(SqliteService, args.d)
    server = ThreadedServer(service, port=args.p)

    server.start()