Пример #1
0
def start_ns(max_allowed_connections=None):
    if Pyro is not None:
        set_maxconnections(max_allowed_connections=max_allowed_connections)
        args = []
        for val in sys.argv[1:]:
            if val.startswith("-n") or val.startswith("--host"):
                args = list(sys.argv[1:])
                break
        else:  # execute when no break occurs
            args = list(sys.argv[1:])
            args.append("-n")
            args.append(str(socket.gethostname()))
        Pyro.naming.main(args)
    else:
        raise ImportError("Pyro or Pyro4 is not installed")
Пример #2
0
def start_ns(max_allowed_connections=None):
    if Pyro is not None:
        set_maxconnections(max_allowed_connections=max_allowed_connections)
        args = []
        for val in sys.argv[1:]:
            if val.startswith("-n") or val.startswith("--host"):
                args = list(sys.argv[1:])
                break
        else: # execute when no break occurs
            args = list(sys.argv[1:])
            args.append("-n")
            args.append(str(socket.gethostname()))
        Pyro.naming.main(args)
    else:
        raise ImportError("Pyro or Pyro4 is not installed")
Пример #3
0
def DispatcherServer(group=":PyUtilibServer",
                     daemon_host=None,
                     daemon_port=0,
                     nameserver_host=None,
                     nameserver_port=None,
                     verbose=False,
                     max_allowed_connections=None,
                     worker_limit=None,
                     clear_group=True):

    set_maxconnections(max_allowed_connections=max_allowed_connections)

    #
    # main program
    #
    ns = get_nameserver(host=nameserver_host,
                        port=nameserver_port,
                        caller_name="Dispatcher")

    if clear_group:
        for name, uri in get_dispatchers(group=group, ns=ns):
            print("Multiple dispatchers not allowed.")
            print("dispatch_srvr is shutting down...")
            return 1

    if using_pyro3:
        daemon = _pyro.core.Daemon(host=daemon_host, port=daemon_port)
        daemon.useNameServer(ns)
    else:
        daemon = _pyro.Daemon(host=daemon_host, port=daemon_port)

    if using_pyro3:
        try:
            ns.createGroup(group)
        except _pyro.errors.NamingError:
            pass
        try:
            ns.createGroup(group + ".dispatcher")
        except _pyro.errors.NamingError:
            pass
        if clear_group:
            try:
                ns.unregister(group + ".dispatcher")
            except _pyro.errors.NamingError:
                pass
    else:
        if clear_group:
            try:
                ns.remove(group + ".dispatcher")
            except _pyro.errors.NamingError:
                pass

    disp = Dispatcher(verbose=verbose, worker_limit=worker_limit)
    proxy_name = group + ".dispatcher." + str(uuid.uuid4())
    if using_pyro3:
        uri = daemon.connect(disp, proxy_name)
    else:
        uri = daemon.register(disp, proxy_name)
        ns.register(proxy_name, uri)

    # There is no need to retain the proxy connection to the
    # nameserver, so free up resources on the nameserver thread
    if using_pyro4:
        ns._pyroRelease()
    else:
        ns._release()

    print("Dispatcher is ready.")
    return daemon.requestLoop()
Пример #4
0
def DispatcherServer(group=":PyUtilibServer",
                     daemon_host=None,
                     daemon_port=0,
                     nameserver_host=None,
                     nameserver_port=None,
                     verbose=False,
                     max_allowed_connections=None,
                     worker_limit=None,
                     clear_group=True):

    set_maxconnections(max_allowed_connections=max_allowed_connections)

    #
    # main program
    #
    ns = get_nameserver(
        host=nameserver_host, port=nameserver_port, caller_name="Dispatcher")

    if clear_group:
        for name, uri in get_dispatchers(group=group, ns=ns):
            print("Multiple dispatchers not allowed.")
            print("dispatch_srvr is shutting down...")
            return 1

    if using_pyro3:
        daemon = _pyro.core.Daemon(host=daemon_host, port=daemon_port)
        daemon.useNameServer(ns)
    else:
        daemon = _pyro.Daemon(host=daemon_host, port=daemon_port)

    if using_pyro3:
        try:
            ns.createGroup(group)
        except _pyro.errors.NamingError:
            pass
        try:
            ns.createGroup(group + ".dispatcher")
        except _pyro.errors.NamingError:
            pass
        if clear_group:
            try:
                ns.unregister(group + ".dispatcher")
            except _pyro.errors.NamingError:
                pass
    else:
        if clear_group:
            try:
                ns.remove(group + ".dispatcher")
            except _pyro.errors.NamingError:
                pass

    disp = Dispatcher(verbose=verbose, worker_limit=worker_limit)
    proxy_name = group + ".dispatcher." + str(uuid.uuid4())
    if using_pyro3:
        uri = daemon.connect(disp, proxy_name)
    else:
        uri = daemon.register(disp, proxy_name)
        ns.register(proxy_name, uri)

    # There is no need to retain the proxy connection to the
    # nameserver, so free up resources on the nameserver thread
    if using_pyro4:
        ns._pyroRelease()
    else:
        ns._release()

    print("Dispatcher is ready.")
    return daemon.requestLoop()
Пример #5
0
def start_ns(max_allowed_connections=None):
    if pyutilib.pyro.Pyro is not None:
        set_maxconnections(max_allowed_connections=max_allowed_connections)
        pyutilib.pyro.Pyro.naming.main(sys.argv[1:])
    else:
        raise ImportError("Pyro or Pyro4 is not installed")