gnes.service.base module¶

class gnes.service.base.BaseService(args)[source]¶

Bases: object

close()[source]¶
default_host = '0.0.0.0'¶
dump(respect_dump_interval=True)[source]¶
handler = <gnes.service.base.MessageHandler object>¶
load_model(base_class, yaml_path=None)[source]¶
Return type:~T
post_init()[source]¶
run()[source]¶
status¶
class gnes.service.base.BetterEnum[source]¶

Bases: enum.Enum

An enumeration.

from_string = <bound method BetterEnum.from_string of <enum 'BetterEnum'>>[source]¶
exception gnes.service.base.BlockMessage[source]¶

Bases: Exception

exception gnes.service.base.ComponentNotLoad[source]¶

Bases: Exception

class gnes.service.base.ConcurrentService[source]¶

Bases: type

exception gnes.service.base.EventLoopEnd[source]¶

Bases: Exception

class gnes.service.base.MessageHandler(mh=None)[source]¶

Bases: object

call_hooks(msg, hook_type, *args, **kwargs)[source]¶

All post handler hooks are called after the handler is done but before sending out the message to the next service. All pre handler hooks are called after the service received a message and before calling the message handler

call_routes(msg)[source]¶
call_routes_send_back(msg, out_sock)[source]¶
register(msg_type)[source]¶
register_hook(hook_type, only_when_verbose=False)[source]¶

Register a function as a pre/post hook

Parameters:
  • only_when_verbose (bool) – only call the hook when verbose is true
  • hook_type (Union[str, Tuple[str]]) – possible values ‘pre’ or ‘post’ or (‘pre’, ‘post’)
class gnes.service.base.ParallelType[source]¶

Bases: gnes.service.base.BetterEnum

An enumeration.

PUB_BLOCK = 2¶
PUB_NONBLOCK = 3¶
PUSH_BLOCK = 0¶
PUSH_NONBLOCK = 1¶
is_block¶
is_push¶
class gnes.service.base.ReduceOp[source]¶

Bases: gnes.service.base.BetterEnum

An enumeration.

ALWAYS_ONE = 1¶
CONCAT = 0¶
exception gnes.service.base.ServiceError[source]¶

Bases: Exception

class gnes.service.base.ServiceManager(service_cls, args)[source]¶

Bases: object

join()[source]¶
class gnes.service.base.SocketType[source]¶

Bases: gnes.service.base.BetterEnum

An enumeration.

PAIR_BIND = 8¶
PAIR_CONNECT = 9¶
PUB_BIND = 6¶
PUB_CONNECT = 7¶
PULL_BIND = 0¶
PULL_CONNECT = 1¶
PUSH_BIND = 2¶
PUSH_CONNECT = 3¶
SUB_BIND = 4¶
SUB_CONNECT = 5¶
is_bind¶
paired¶
gnes.service.base.build_socket(ctx, host, port, socket_type, identity=None, use_ipc=False)[source]¶
Return type:Tuple[Socket, str]
gnes.service.base.get_random_ipc()[source]¶
Return type:str
gnes.service.base.send_ctrl_message(address, msg, timeout)[source]¶