1
0
forked from bot/app
LiteyukiBot/assets/storage.html-DT2OMrrn.js

222 lines
68 KiB
JavaScript
Raw Normal View History

import{_ as n,o as s,c as a,e}from"./app-SlpTmndF.js";const t={},p=e(`<h3 id="def-run-subscriber-receive-funcs-channel-str-data-any-none" tabindex="-1"><a class="header-anchor" href="#def-run-subscriber-receive-funcs-channel-str-data-any-none"><span><em><strong>def</strong></em> <code>run_subscriber_receive_funcs(channel_: str, data: Any) -&gt; None</code></span></a></h3><p>运行订阅者接收函数</p><p>Args:</p><pre><code>channel_: 频道
data: 数据
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@staticmethod</span>
<span class="token keyword">def</span> <span class="token function">run_subscriber_receive_funcs</span><span class="token punctuation">(</span>channel_<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
运行订阅者接收函数
Args:
channel_: 频道
data: 数据
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">in</span> _on_main_subscriber_receive_funcs <span class="token keyword">and</span> _on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">:</span>
run_coroutine_in_thread<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">[</span>func<span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token keyword">for</span> func <span class="token keyword">in</span> _on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword">elif</span> channel_ <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs <span class="token keyword">and</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">:</span>
run_coroutine_in_thread<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">[</span>func<span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token keyword">for</span> func <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-get-data-tuple-str-dict-str-any-none" tabindex="-1"><a class="header-anchor" href="#def-on-get-data-tuple-str-dict-str-any-none"><span><em><strong>def</strong></em> <code>on_get(data: tuple[str, dict[str, Any]]) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@shared_memory<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>on_receive</span><span class="token punctuation">(</span><span class="token keyword">lambda</span> d<span class="token punctuation">:</span> d<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">&#39;get&#39;</span><span class="token punctuation">)</span>
<span class="token keyword">def</span> <span class="token function">on_get</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> <span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
key <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">]</span>
default <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;default&#39;</span><span class="token punctuation">]</span>
recv_chan <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">]</span>
recv_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span>shared_memory<span class="token punctuation">.</span>get<span class="token punctuation">(</span>key<span class="token punctuation">,</span> default<span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-set-data-tuple-str-dict-str-any-none" tabindex="-1"><a class="header-anchor" href="#def-on-set-data-tuple-str-dict-str-any-none"><span><em><strong>def</strong></em> <code>on_set(data: tuple[str, dict[str, Any]]) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@shared_memory<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>on_receive</span><span class="token punctuation">(</span><span class="token keyword">lambda</span> d<span class="token punctuation">:</span> d<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">&#39;set&#39;</span><span class="token punctuation">)</span>
<span class="token keyword">def</span> <span class="token function">on_set</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> <span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
key <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">]</span>
value <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;value&#39;</span><span class="token punctuation">]</span>
shared_memory<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>key<span class="token punctuation">,</span> value<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-delete-data-tuple-str-dict-str-any-none" tabindex="-1"><a class="header-anchor" href="#def-on-delete-data-tuple-str-dict-str-any-none"><span><em><strong>def</strong></em> <code>on_delete(data: tuple[str, dict[str, Any]]) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@shared_memory<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>on_receive</span><span class="token punctuation">(</span><span class="token keyword">lambda</span> d<span class="token punctuation">:</span> d<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">&#39;delete&#39;</span><span class="token punctuation">)</span>
<span class="token keyword">def</span> <span class="token function">on_delete</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> <span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
key <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">]</span>
shared_memory<span class="token punctuation">.</span>delete<span class="token punctuation">(</span>key<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-get-all-data-tuple-str-dict-str-any-none" tabindex="-1"><a class="header-anchor" href="#def-on-get-all-data-tuple-str-dict-str-any-none"><span><em><strong>def</strong></em> <code>on_get_all(data: tuple[str, dict[str, Any]]) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@shared_memory<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>on_receive</span><span class="token punctuation">(</span><span class="token keyword">lambda</span> d<span class="token punctuation">:</span> d<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">&#39;get_all&#39;</span><span class="token punctuation">)</span>
<span class="token keyword">def</span> <span class="token function">on_get_all</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> <span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
recv_chan <span class="token operator">=</span> data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">]</span>
recv_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span>shared_memory<span class="token punctuation">.</span>get_all<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-publish-data-tuple-str-any-none" tabindex="-1"><a class="header-anchor" href="#def-on-publish-data-tuple-str-any-none"><span><em><strong>def</strong></em> <code>on_publish(data: tuple[str, Any]) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@channel<span class="token punctuation">.</span>publish_channel<span class="token punctuation">.</span>on_receive</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">def</span> <span class="token function">on_publish</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> <span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token punctuation">(</span>channel_<span class="token punctuation">,</span> data<span class="token punctuation">)</span> <span class="token operator">=</span> data
shared_memory<span class="token punctuation">.</span>run_subscriber_receive_funcs<span class="token punctuation">(</span>channel_<span class="token punctuation">,</span> data<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-decorator-func-on-receive-func-on-receive-func" tabindex="-1"><a class="header-anchor" href="#def-decorator-func-on-receive-func-on-receive-func"><span><em><strong>def</strong></em> <code>decorator(func: ON_RECEIVE_FUNC) -&gt; ON_RECEIVE_FUNC</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">decorator</span><span class="token punctuation">(</span>func<span class="token punctuation">:</span> ON_RECEIVE_FUNC<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> ON_RECEIVE_FUNC<span class="token punctuation">:</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">wrapper</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> is_coroutine_callable<span class="token punctuation">(</span>func<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">await</span> func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">not</span> <span class="token keyword">in</span> _on_main_subscriber_receive_funcs<span class="token punctuation">:</span>
_on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
_on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">.</span>append<span class="token punctuation">(</span>wrapper<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">not</span> <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">:</span>
_on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
_on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">.</span>append<span class="token punctuation">(</span>wrapper<span class="token punctuation">)</span>
<span class="token keyword">return</span> wrapper
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="async-def-wrapper-data-any-none" tabindex="-1"><a class="header-anchor" href="#async-def-wrapper-data-any-none"><span><em><strong>async def</strong></em> <code>wrapper(data: Any) -&gt; None</code></span></a></h3><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">wrapper</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> is_coroutine_callable<span class="token punctuation">(</span>func<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">await</span> func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="class-subscriber" tabindex="-1"><a class="header-anchor" href="#class-subscriber"><span><em><strong>class</strong></em> <code>Subscriber</code></span></a></h3><h3 id="def-init-self-none" tabindex="-1"><a class="header-anchor" href="#def-init-self-none"><span> <em><strong>def</strong></em> <code>__init__(self) -&gt; None</code></span></a></h3><p></p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">__init__</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span><span class="token punctuation">:</span>
self<span class="token punctuation">.</span>_subscribers <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-receive-self-any" tabindex="-1"><a class="header-anchor" href="#def-receive-self-any"><span> <em><strong>def</strong></em> <code>receive(self) -&gt; Any</code></span></a></h3><p></p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">receive</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> Any<span class="token punctuation">:</span>
<span class="token keyword">pass</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-unsubscribe-self-none" tabindex="-1"><a class="header-anchor" href="#def-unsubscribe-self-none"><span> <em><strong>def</strong></em> <code>unsubscribe(self) -&gt; None</code></span></a></h3><p></p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">unsubscribe</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token keyword">pass</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="class-keyvaluestore" tabindex="-1"><a class="header-anchor" href="#class-keyvaluestore"><span><em><strong>class</strong></em> <code>KeyValueStore</code></span></a></h3><h3 id="def-init-self-none-1" tabindex="-1"><a class="header-anchor" href="#def-init-self-none-1"><span> <em><strong>def</strong></em> <code>__init__(self) -&gt; None</code></span></a></h3><p></p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">__init__</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span><span class="token punctuation">:</span>
self<span class="token punctuation">.</span>_store <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
self<span class="token punctuation">.</span>active_chan <span class="token operator">=</span> Channel<span class="token punctuation">[</span><span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Optional<span class="token punctuation">[</span><span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">(</span>_id<span class="token operator">=</span><span class="token string">&#39;shared_memory-active&#39;</span><span class="token punctuation">)</span>
self<span class="token punctuation">.</span>passive_chan <span class="token operator">=</span> Channel<span class="token punctuation">[</span><span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Optional<span class="token punctuation">[</span><span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">(</span>_id<span class="token operator">=</span><span class="token string">&#39;shared_memory-passive&#39;</span><span class="token punctuation">)</span>
self<span class="token punctuation">.</span>publish_channel <span class="token operator">=</span> Channel<span class="token punctuation">[</span><span class="token builtin">tuple</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">(</span>_id<span class="token operator">=</span><span class="token string">&#39;shared_memory-publish&#39;</span><span class="token punctuation">)</span>
self<span class="token punctuation">.</span>is_main_receive_loop_running <span class="token operator">=</span> <span class="token boolean">False</span>
self<span class="token punctuation">.</span>is_sub_receive_loop_running <span class="token operator">=</span> <span class="token boolean">False</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-set-self-key-str-value-any-none" tabindex="-1"><a class="header-anchor" href="#def-set-self-key-str-value-any-none"><span> <em><strong>def</strong></em> <code>set(self, key: str, value: Any) -&gt; None</code></span></a></h3><p></p><p>Args:</p><pre><code>key:
value:
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">set</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> key<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> Any<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
设置键值对
Args:
key:
value:
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
lock <span class="token operator">=</span> _get_lock<span class="token punctuation">(</span>key<span class="token punctuation">)</span>
<span class="token keyword">with</span> lock<span class="token punctuation">:</span>
self<span class="token punctuation">.</span>_store<span class="token punctuation">[</span>key<span class="token punctuation">]</span> <span class="token operator">=</span> value
<span class="token keyword">else</span><span class="token punctuation">:</span>
self<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">&#39;set&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">:</span> key<span class="token punctuation">,</span> <span class="token string">&#39;value&#39;</span><span class="token punctuation">:</span> value<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-get-self-key-str-default-optional-any-optional-any" tabindex="-1"><a class="header-anchor" href="#def-get-self-key-str-default-optional-any-optional-any"><span> <em><strong>def</strong></em> <code>get(self, key: str, default: Optional[Any]) -&gt; Optional[Any]</code></span></a></h3><p></p><p>Args:</p><pre><code>key:
default: 默认值
</code></pre><p>Returns:</p><pre><code>Any:
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">get</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> key<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> default<span class="token punctuation">:</span> Optional<span class="token punctuation">[</span>Any<span class="token punctuation">]</span><span class="token operator">=</span><span class="token boolean">None</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> Optional<span class="token punctuation">[</span>Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
获取键值对
Args:
key:
default: 默认值
Returns:
Any:
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
lock <span class="token operator">=</span> _get_lock<span class="token punctuation">(</span>key<span class="token punctuation">)</span>
<span class="token keyword">with</span> lock<span class="token punctuation">:</span>
<span class="token keyword">return</span> self<span class="token punctuation">.</span>_store<span class="token punctuation">.</span>get<span class="token punctuation">(</span>key<span class="token punctuation">,</span> default<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
recv_chan <span class="token operator">=</span> Channel<span class="token punctuation">[</span>Optional<span class="token punctuation">[</span>Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">)</span>
self<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">&#39;get&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">:</span> key<span class="token punctuation">,</span> <span class="token string">&#39;default&#39;</span><span class="token punctuation">:</span> default<span class="token punctuation">,</span> <span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">:</span> recv_chan<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">return</span> recv_chan<span class="token punctuation">.</span>receive<span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-delete-self-key-str-ignore-key-error-bool-none" tabindex="-1"><a class="header-anchor" href="#def-delete-self-key-str-ignore-key-error-bool-none"><span> <em><strong>def</strong></em> <code>delete(self, key: str, ignore_key_error: bool) -&gt; None</code></span></a></h3><p></p><p>Args:</p><pre><code>key:
ignore_key_error: 是否忽略键不存在的错误
</code></pre><p>Returns:</p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">delete</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> key<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> ignore_key_error<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">True</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
删除键值对
Args:
key:
ignore_key_error: 是否忽略键不存在的错误
Returns:
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
lock <span class="token operator">=</span> _get_lock<span class="token punctuation">(</span>key<span class="token punctuation">)</span>
<span class="token keyword">with</span> lock<span class="token punctuation">:</span>
<span class="token keyword">if</span> key <span class="token keyword">in</span> self<span class="token punctuation">.</span>_store<span class="token punctuation">:</span>
<span class="token keyword">try</span><span class="token punctuation">:</span>
<span class="token keyword">del</span> self<span class="token punctuation">.</span>_store<span class="token punctuation">[</span>key<span class="token punctuation">]</span>
<span class="token keyword">del</span> _locks<span class="token punctuation">[</span>key<span class="token punctuation">]</span>
<span class="token keyword">except</span> KeyError <span class="token keyword">as</span> e<span class="token punctuation">:</span>
<span class="token keyword">if</span> <span class="token keyword">not</span> ignore_key_error<span class="token punctuation">:</span>
<span class="token keyword">raise</span> e
<span class="token keyword">else</span><span class="token punctuation">:</span>
self<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">&#39;delete&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token string">&#39;key&#39;</span><span class="token punctuation">:</span> key<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-get-all-self-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-get-all-self-dict-str-any"><span> <em><strong>def</strong></em> <code>get_all(self) -&gt; dict[str, Any]</code></span></a></h3><p></p><p>Returns:</p><pre><code>dict[str, Any]:
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">get_all</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
获取所有键值对
Returns:
dict[str, Any]: 键值对
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
<span class="token keyword">return</span> self<span class="token punctuation">.</span>_store
<span class="token keyword">else</span><span class="token punctuation">:</span>
recv_chan <span class="token operator">=</span> Channel<span class="token punctuation">[</span><span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">)</span>
self<span class="token punctuation">.</span>passive_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">&#39;get_all&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token string">&#39;recv_chan&#39;</span><span class="token punctuation">:</span> recv_chan<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">return</span> recv_chan<span class="token punctuation">.</span>receive<span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-publish-self-channel-str-data-any-none" tabindex="-1"><a class="header-anchor" href="#def-publish-self-channel-str-data-any-none"><span> <em><strong>def</strong></em> <code>publish(self, channel_: str, data: Any) -&gt; None</code></span></a></h3><p></p><p>Args:</p><pre><code>channel_:
data: 数据
</code></pre><p>Returns:</p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">publish</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> channel_<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
发布消息
Args:
channel_: 频道
data: 数据
Returns:
&quot;&quot;&quot;</span>
self<span class="token punctuation">.</span>active_chan<span class="token punctuation">.</span>send<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">&#39;publish&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token string">&#39;channel&#39;</span><span class="token punctuation">:</span> channel_<span class="token punctuation">,</span> <span class="token string">&#39;data&#39;</span><span class="token punctuation">:</span> data<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-on-subscriber-receive-self-channel-str-callable-on-receive-func-on-receive-func" tabindex="-1"><a class="header-anchor" href="#def-on-subscriber-receive-self-channel-str-callable-on-receive-func-on-receive-func"><span> <em><strong>def</strong></em> <code>on_subscriber_receive(self, channel_: str) -&gt; Callable[[ON_RECEIVE_FUNC], ON_RECEIVE_FUNC]</code></span></a></h3><p></p><p>Args:</p><pre><code>channel_:
</code></pre><p>Returns:</p><pre><code>
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">on_subscriber_receive</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> channel_<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> Callable<span class="token punctuation">[</span><span class="token punctuation">[</span>ON_RECEIVE_FUNC<span class="token punctuation">]</span><span class="token punctuation">,</span> ON_RECEIVE_FUNC<span class="token punctuation">]</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
订阅者接收消息时的回调
Args:
channel_: 频道
Returns:
装饰器
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS <span class="token keyword">and</span> <span class="token punctuation">(</span><span class="token keyword">not</span> self<span class="token punctuation">.</span>is_main_receive_loop_running<span class="token punctuation">)</span><span class="token punctuation">:</span>
threading<span class="token punctuation">.</span>Thread<span class="token punctuation">(</span>target<span class="token operator">=</span>self<span class="token punctuation">.</span>_start_receive_loop<span class="token punctuation">,</span> daemon<span class="token operator">=</span><span class="token boolean">True</span><span class="token punctuation">)</span><span class="token punctuation">.</span>start<span class="token punctuation">(</span><span class="token punctuation">)</span>
shared_memory<span class="token punctuation">.</span>is_main_receive_loop_running <span class="token operator">=</span> <span class="token boolean">True</span>
<span class="token keyword">elif</span> <span class="token keyword">not</span> IS_MAIN_PROCESS <span class="token keyword">and</span> <span class="token punctuation">(</span><span class="token keyword">not</span> self<span class="token punctuation">.</span>is_sub_receive_loop_running<span class="token punctuation">)</span><span class="token punctuation">:</span>
threading<span class="token punctuation">.</span>Thread<span class="token punctuation">(</span>target<span class="token operator">=</span>self<span class="token punctuation">.</span>_start_receive_loop<span class="token punctuation">,</span> daemon<span class="token operator">=</span><span class="token boolean">True</span><span class="token punctuation">)</span><span class="token punctuation">.</span>start<span class="token punctuation">(</span><span class="token punctuation">)</span>
shared_memory<span class="token punctuation">.</span>is_sub_receive_loop_running <span class="token operator">=</span> <span class="token boolean">True</span>
<span class="token keyword">def</span> <span class="token function">decorator</span><span class="token punctuation">(</span>func<span class="token punctuation">:</span> ON_RECEIVE_FUNC<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> ON_RECEIVE_FUNC<span class="token punctuation">:</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">wrapper</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> is_coroutine_callable<span class="token punctuation">(</span>func<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">await</span> func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
func<span class="token punctuation">(</span>data<span class="token punctuation">)</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">not</span> <span class="token keyword">in</span> _on_main_subscriber_receive_funcs<span class="token punctuation">:</span>
_on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
_on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">.</span>append<span class="token punctuation">(</span>wrapper<span class="token punctuation">)</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">not</span> <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">:</span>
_on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
_on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">.</span>append<span class="token punctuation">(</span>wrapper<span class="token punctuation">)</span>
<span class="token keyword">return</span> wrapper
<span class="token keyword">return</span> decorator
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="staticmethod" tabindex="-1"><a class="header-anchor" href="#staticmethod"><span> <em><strong>@staticmethod</strong></em></span></a></h3><h3 id="def-run-subscriber-receive-funcs-channel-str-data-any-none-1" tabindex="-1"><a class="header-anchor" href="#def-run-subscriber-receive-funcs-channel-str-data-any-none-1"><span> <em><strong>def</strong></em> <code>run_subscriber_receive_funcs(channel_: str, data: Any) -&gt; None</code></span></a></h3><p></p><p>Args:</p><pre><code>channel_:
data: 数据
</code></pre><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@staticmethod</span>
<span class="token keyword">def</span> <span class="token function">run_subscriber_receive_funcs</span><span class="token punctuation">(</span>channel_<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> data<span class="token punctuation">:</span> Any<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token triple-quoted-string string">&quot;&quot;&quot;
运行订阅者接收函数
Args:
channel_: 频道
data: 数据
&quot;&quot;&quot;</span>
<span class="token keyword">if</span> IS_MAIN_PROCESS<span class="token punctuation">:</span>
<span class="token keyword">if</span> channel_ <span class="token keyword">in</span> _on_main_subscriber_receive_funcs <span class="token keyword">and</span> _on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">:</span>
run_coroutine_in_thread<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">[</span>func<span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token keyword">for</span> func <span class="token keyword">in</span> _on_main_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword">elif</span> channel_ <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs <span class="token keyword">and</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">:</span>
run_coroutine_in_thread<span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">[</span>func<span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token keyword">for</span> func <span class="token keyword">in</span> _on_sub_subscriber_receive_funcs<span class="token punctuation">[</span>channel_<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="class-globalkeyvaluestore" tabindex="-1"><a class="header-anchor" href="#class-globalkeyvaluestore"><span><em><strong>class</strong></em> <code>GlobalKeyValueStore</code></span></a></h3><h3 id="classmethod" tabindex="-1"><a class="header-anchor" href="#classmethod"><span> <em><strong>@classmethod</strong></em></span></a></h3><h3 id="def-get-instance-cls-any-none" tabindex="-1"><a class="header-anchor" href="#def-get-instance-cls-any-none"><span> <em><strong>def</strong></em> <code>get_instance(cls: Any) -&gt; None</code></span></a></h3><p></p><details><summary></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@classmethod</span>
<span class="token keyword">def</span> <span class="token function">get_instance</span><span class="token punctuation">(</span>cls<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> cls<span class="token punctuation">.</span>_instance <span class="token keyword">is</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token keyword">with</span> cls<span class="token punctuation">.</span>_lock<span class="token punctuation">:</span>
<span class="token keyword">if</span> cls<span class="token punctuation">.</span>_instance <span class="token keyword">is</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
cls<span class="token punctuation">.</span>_instance <span class="token operator">=</span> KeyValueStore<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">return</span> cls<span class="token punctuation">.</span>_instance
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="attr-instance-none" tabindex="-1"><a class="header-anchor" href="#attr-instance-none"><span> <em><strong>attr</strong></em> <code>_instance: None</code></span></a></h3><h3 id="attr-lock-threading-lock" tabindex="-1"><a class="header-anchor" href="#attr-lock-threading-lock"><span> <em><strong>attr</strong></em> <code>_lock: threading.Lock()</code></span></a></h3><h3 id="var-key-data-1-key" tabindex="-1"><a class="header-anchor" href="#var-key-data-1-key"><span><em><strong>var</strong></em> <code>key = data[1][&#39;key&#39;]</code></span></a></h3><h3 id="var-default-data-1-default" tabindex="-1"><a class="header-anchor" href="#var-default-data-1-default"><span><em><strong>var</strong></em> <code>default = data[1][&#39;default&#39;]</code></span></a></h3><h3 id="var-recv-chan-data-1-recv-chan" tabindex="-1"><a class="header-anchor" href="#var-recv-chan-data-1-recv-chan"><span><em><strong>var</strong></em> <code>recv_chan = data[1][&#39;recv_chan&#39;]</code></span></a></h3><h3 id="var-key-data-1-key-1" tabindex="-1"><a class="header-anchor" href="#var-key-data-1-key-1"><span><em><strong>var</strong></em> <code>key = data[1][&#39;key&#39;]</code></span></a></h3><h3 id="var-value-data-1-value" tabindex="-1"><a class="header-anchor" href="#var-value-data-1-value"><span><em><strong>var</strong></em> <code>value = data[1][&#39;value&#39;]</code></span></a></h3><h3 id="var-key-data-1-key-2" tabindex="-1"><a class="header-anchor" href="#var-key-data-1-key-2"><span><em><strong>var</strong></em> <code>key = data[1][&#39;key&#39;]</code></span></a></h3><h3 id="var-recv-chan-data-1-recv-chan-1" tabindex="-1"><a class="header-anchor" href="#var-recv-chan-data-1-recv-chan-1"><span><em><strong>var</strong></em> <code>recv_chan = data[1][&#39;recv_chan&#39;]</code></span></a></h3><h3 id="var-lock-get-lock-key" tabindex="-1"><a class="header-anchor" href="#var-lock-get-lock-key"><span><em><strong>var</strong></em> <code>lock = _get_lock(key)</code></span></a></h3><h3 id="var-lock-get-lock-key-1" tabindex="-1"><a class="header-anchor" href="#var-lock-get-lock-key-1"><span><em><strong>var</strong></em> <code>lock = _get_lock(key)</code></span></a></h3><h3 id="var-recv-chan-channel-optional-any-recv-chan" tabindex="-1"><a class="header-anchor" href="#var-recv-chan-channel-optional-any-recv-chan"><span><em><strong>var</strong></em> <code>recv_chan = Channel[Optional[Any]](&#39;recv_chan&#39;)</code></span></a></h3><h3 id="var-lock-get-lock-key-2" tabindex="-1"><a class="header-anchor" href="#var-lock-get-lock-key-2"><span><em><strong>var</strong></em> <code>lock = _get_lock(key)</code></span></a></h3><h3 id="var-recv-chan-channel-dict-str-any-recv-chan" tabindex="-1"><a class="header-anchor" href="#var-recv-chan-channel-dict-str-any-recv-chan"><span><em><strong>var</strong></em> <code>recv_chan = Channel[dict[str, Any]](&#39;recv_chan&#39;)</code></span></a></h3><h3 id="var-data-self-active-chan-receive" tabindex="-1"><a class="header-anchor" href="#var-data-self-active-chan-receive"><span><em><strong>var</strong></em> <code>data = self.active_chan.receive()</code></span></a></h3><h3 id="var-data-self-publish-channel-receive" tabindex="-1"><a class="header-anchor" href="#var-data-self-publish-channel-receive"><span><em><strong>var</strong></em> <code>data = self.publish_channel.receive()</code></span></a></h3>`,96),c=[p];function o(l,i){return s(),a("div",null,c)}const r=n(t,[["render",o],["__file","storage.html.vue"]]),d=JSON.parse(`{"path":"/en/dev/api/comm/storage.html","title":"liteyuki.comm.storage","lang":"en-US","frontmatter":{"title":"liteyuki.comm.storage","order":1,"icon":"laptop-code","category":"API","description":"def run_subscriber_receive_funcs(channel_: str, data: Any) -> None Args: d