跳至主要內容

liteyuki.core.manager

远野千束小于 1 分钟API

class ChannelDeliver

def __init__(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[str, dict]], publish: Channel[tuple[str, Any]]) -> None

class ProcessManager

进程管理器

def __init__(self, lifespan: 'Lifespan') -> None

def start(self, name: str) -> None

 开启后自动监控进程,并添加到进程字典中

Args:

name:

Returns:

def start_all(self) -> None

 启动所有进程

def add_target(self, name: str, target: TARGET_FUNC, args: tuple, kwargs: Any) -> None

 添加进程

Args:

name: 进程名,用于获取和唯一标识

target: 进程函数

args: 进程函数参数

kwargs: 进程函数关键字参数,通常会默认传入chan_active和chan_passive

def join_all(self) -> None

def terminate(self, name: str) -> None

 终止进程并从进程字典中删除

Args:

name:

Returns:

def terminate_all(self) -> None

def is_process_alive(self, name: str) -> bool

 检查进程是否存活

Args:

name:

Returns:

var TIMEOUT = 10

var chan_active = get_channel(f'{name}-active')

var channel_deliver = ChannelDeliver(active=chan_active, passive=chan_passive, channel_deliver_active=channel_deliver_active_channel, channel_deliver_passive=channel_deliver_passive_channel, publish=publish_channel)

var process = self.processes[name]

var process = Process(target=self.targets[name][0], args=self.targets[name][1], kwargs=self.targets[name][2], daemon=True)

var data = chan_active.receive()

var kwargs = {}