mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-15 09:44:27 +08:00
12 lines
12 KiB
JavaScript
12 lines
12 KiB
JavaScript
|
import{_ as e,o as a,c as n,e as s}from"./app-Dk7jq3Nw.js";const l={},t=s(`<h3 id="class-channeldeliver" tabindex="-1"><a class="header-anchor" href="#class-channeldeliver"><span><em><strong>class</strong></em> <code>ChannelDeliver</code></span></a></h3><h3 id="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" tabindex="-1"><a class="header-anchor" href="#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"><span> <em><strong>def</strong></em> <code>__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</code></span></a></h3><p> </p><h3 id="class-processmanager" tabindex="-1"><a class="header-anchor" href="#class-processmanager"><span><em><strong>class</strong></em> <code>ProcessManager</code></span></a></h3><p>进程管理器</p><h3 id="def-init-self-lifespan-lifespan-none" tabindex="-1"><a class="header-anchor" href="#def-init-self-lifespan-lifespan-none"><span> <em><strong>def</strong></em> <code>__init__(self, lifespan: 'Lifespan') -> None</code></span></a></h3><p> </p><h3 id="def-start-self-name-str-none" tabindex="-1"><a class="header-anchor" href="#def-start-self-name-str-none"><span> <em><strong>def</strong></em> <code>start(self, name: str) -> None</code></span></a></h3><p> 开启后自动监控进程,并添加到进程字典中</p><p>Args:</p><pre><code>name:
|
|||
|
</code></pre><p>Returns:</p><h3 id="def-start-all-self-none" tabindex="-1"><a class="header-anchor" href="#def-start-all-self-none"><span> <em><strong>def</strong></em> <code>start_all(self) -> None</code></span></a></h3><p> 启动所有进程</p><h3 id="def-add-target-self-name-str-target-target-func-args-tuple-kwargs-any-none" tabindex="-1"><a class="header-anchor" href="#def-add-target-self-name-str-target-target-func-args-tuple-kwargs-any-none"><span> <em><strong>def</strong></em> <code>add_target(self, name: str, target: TARGET_FUNC, args: tuple, kwargs: Any) -> None</code></span></a></h3><p> 添加进程</p><p>Args:</p><pre><code>name: 进程名,用于获取和唯一标识
|
|||
|
|
|||
|
target: 进程函数
|
|||
|
|
|||
|
args: 进程函数参数
|
|||
|
|
|||
|
kwargs: 进程函数关键字参数,通常会默认传入chan_active和chan_passive
|
|||
|
</code></pre><h3 id="def-join-all-self-none" tabindex="-1"><a class="header-anchor" href="#def-join-all-self-none"><span> <em><strong>def</strong></em> <code>join_all(self) -> None</code></span></a></h3><p> </p><h3 id="def-terminate-self-name-str-none" tabindex="-1"><a class="header-anchor" href="#def-terminate-self-name-str-none"><span> <em><strong>def</strong></em> <code>terminate(self, name: str) -> None</code></span></a></h3><p> 终止进程并从进程字典中删除</p><p>Args:</p><pre><code>name:
|
|||
|
</code></pre><p>Returns:</p><h3 id="def-terminate-all-self-none" tabindex="-1"><a class="header-anchor" href="#def-terminate-all-self-none"><span> <em><strong>def</strong></em> <code>terminate_all(self) -> None</code></span></a></h3><p> </p><h3 id="def-is-process-alive-self-name-str-bool" tabindex="-1"><a class="header-anchor" href="#def-is-process-alive-self-name-str-bool"><span> <em><strong>def</strong></em> <code>is_process_alive(self, name: str) -> bool</code></span></a></h3><p> 检查进程是否存活</p><p>Args:</p><pre><code>name:
|
|||
|
</code></pre><p>Returns:</p><h3 id="var-timeout-10" tabindex="-1"><a class="header-anchor" href="#var-timeout-10"><span><em><strong>var</strong></em> <code>TIMEOUT = 10</code></span></a></h3><h3 id="var-chan-active-get-channel-f-name-active" tabindex="-1"><a class="header-anchor" href="#var-chan-active-get-channel-f-name-active"><span><em><strong>var</strong></em> <code>chan_active = get_channel(f'{name}-active')</code></span></a></h3><h3 id="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" tabindex="-1"><a class="header-anchor" href="#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"><span><em><strong>var</strong></em> <code>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)</code></span></a></h3><h3 id="var-process-self-processes-name" tabindex="-1"><a class="header-anchor" href="#var-process-self-processes-name"><span><em><strong>var</strong></em> <code>process = self.processes[name]</code></span></a></h3><h3 id="var-process-process-target-self-targets-name-0-args-self-targets-name-1-kwargs-self-targets-name-2-daemon-true" tabindex="-1"><a class="header-anchor" href="#var-process-process-target-self-targets-name-0-args-self-targets-name-1-kwargs-self-targets-name-2-daemon-true"><span><em><strong>var</strong></em> <code>process = Process(target=self.targets[name][0], args=self.targets[name][1], kwargs=self.targets[name][2], daemon=True)</code></span></a></h3><h3 id="var-data-chan-active-receive" tabindex="-1"><a class="header-anchor" href="#var-data-chan-active-receive"><span><em><strong>var</strong></em> <code>data = chan_active.receive()</code></span></a></h3><h3 id="var-kwargs" tabindex="-1"><a class="header-anchor" href="#var-kwargs"><span><em><strong>var</strong></em> <code>kwargs = {}</code></span></a></h3>`,39),r=[t];function i(c,h){return a(),n("div",null,r)}const d=e(l,[["render",i],["__file","manager.html.vue"]]),p=JSON.parse(`{"path":"/dev/api/core/manager.html","title":"liteyuki.core.manager","lang":"zh-CN","frontmatter":{"title":"liteyuki.core.manager","order":1,"icon":"laptop-code","category":"API","description":"class ChannelDeliver def __init__(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[str, d...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/core/manager.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/core/manager.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.core.manager"}],["meta",{"property":"og:description","content":"class ChannelDeliver def __init__(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[str, d..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["meta",{"property":"og:updated_time","content":"2024-08-19T02:22:24.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-19T02:22:24.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.core.manager\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-19T02:22:24.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"class ChannelDeliver","slug":"class-channeldeliver","link":"#class-channeldeliver","children":[]},{"level":3,"title":"
|