Skip to content

Commit

Permalink
deploy: b070e8b
Browse files Browse the repository at this point in the history
  • Loading branch information
MountainGod2 committed Dec 20, 2024
1 parent ed1f0b3 commit 3ad2ff4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
2 changes: 1 addition & 1 deletion _modules/chaturbate_poller/logging_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h1>Source code for chaturbate_poller.logging_config</h1><div class="highlight">

<div class="viewcode-block" id="SanitizeSensitiveDataFilter">
<a class="viewcode-back" href="../../autoapi/chaturbate_poller/logging_config/index.html#chaturbate_poller.logging_config.SanitizeSensitiveDataFilter">[docs]</a>
<span class="k">class</span> <span class="nc">SanitizeSensitiveDataFilter</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">Filter</span><span class="p">):</span>
<span class="k">class</span> <span class="nc">SanitizeSensitiveDataFilter</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">Filter</span><span class="p">):</span> <span class="c1"># pylint: disable=R0903</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Filter to sanitize sensitive data from logs.&quot;&quot;&quot;</span>

<div class="viewcode-block" id="SanitizeSensitiveDataFilter.filter">
Expand Down
10 changes: 5 additions & 5 deletions _modules/chaturbate_poller/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h1>Source code for chaturbate_poller.main</h1><div class="highlight"><pre>

<span class="nd">@click</span><span class="o">.</span><span class="n">group</span><span class="p">()</span>
<span class="nd">@click</span><span class="o">.</span><span class="n">version_option</span><span class="p">(</span><span class="n">version</span><span class="o">=</span><span class="n">__version__</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">cli</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">cli</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span> <span class="c1"># pragma: no cover</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Manage and run the Chaturbate Poller CLI.&quot;&quot;&quot;</span>


Expand Down Expand Up @@ -143,7 +143,7 @@ <h1>Source code for chaturbate_poller.main</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="nd">@click</span><span class="o">.</span><span class="n">option</span><span class="p">(</span><span class="s2">&quot;--testbed&quot;</span><span class="p">,</span> <span class="n">is_flag</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s2">&quot;Enable testbed mode.&quot;</span><span class="p">)</span>
<span class="nd">@click</span><span class="o">.</span><span class="n">option</span><span class="p">(</span><span class="s2">&quot;--verbose&quot;</span><span class="p">,</span> <span class="n">is_flag</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s2">&quot;Enable verbose logging.&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">start</span><span class="p">(</span> <span class="c1"># noqa: PLR0913</span>
<span class="k">def</span> <span class="nf">start</span><span class="p">(</span> <span class="c1"># noqa: PLR0913 # pylint: disable=too-many-arguments # pragma: no cover</span>
<span class="n">username</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">token</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">timeout</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
Expand All @@ -168,7 +168,7 @@ <h1>Source code for chaturbate_poller.main</h1><div class="highlight"><pre>

<div class="viewcode-block" id="main">
<a class="viewcode-back" href="../../autoapi/chaturbate_poller/main/index.html#chaturbate_poller.main.main">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">main</span><span class="p">(</span> <span class="c1"># noqa: PLR0913</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">main</span><span class="p">(</span> <span class="c1"># noqa: PLR0913 # pylint: disable=too-many-arguments # pragma: no cover</span>
<span class="n">username</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">token</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">api_timeout</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
Expand Down Expand Up @@ -230,7 +230,7 @@ <h1>Source code for chaturbate_poller.main</h1><div class="highlight"><pre>

<div class="viewcode-block" id="start_polling">
<a class="viewcode-back" href="../../autoapi/chaturbate_poller/main/index.html#chaturbate_poller.main.start_polling">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">start_polling</span><span class="p">(</span> <span class="c1"># noqa: PLR0913</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">start_polling</span><span class="p">(</span> <span class="c1"># noqa: PLR0913 # pylint: disable=too-many-arguments # pragma: no cover</span>
<span class="n">username</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">token</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">api_timeout</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
Expand Down Expand Up @@ -267,7 +267,7 @@ <h1>Source code for chaturbate_poller.main</h1><div class="highlight"><pre>



<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span> <span class="c1"># pragma: no cover</span>
<span class="n">cli</span><span class="p">()</span>
</pre></div>

Expand Down
29 changes: 23 additions & 6 deletions _modules/chaturbate_poller/signal_handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,22 @@ <h1>Source code for chaturbate_poller.signal_handler</h1><div class="highlight">
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">loop</span> <span class="o">=</span> <span class="n">loop</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop_future</span> <span class="o">=</span> <span class="n">stop_future</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_is_setup</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;SignalHandler initialized.&quot;</span><span class="p">)</span>

<div class="viewcode-block" id="SignalHandler.setup">
<a class="viewcode-back" href="../../autoapi/chaturbate_poller/signal_handler/index.html#chaturbate_poller.signal_handler.SignalHandler.setup">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Set up signal handlers for SIGINT and SIGTERM asynchronously.&quot;&quot;&quot;</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Set up signal handlers for SIGINT and SIGTERM asynchronously.</span>

<span class="sd"> Raises:</span>
<span class="sd"> RuntimeError: If setup is called more than once.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_setup</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s2">&quot;SignalHandler.setup() has already been called.&quot;</span>
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_is_setup</span> <span class="o">=</span> <span class="kc">True</span>

<span class="bp">self</span><span class="o">.</span><span class="n">loop</span><span class="o">.</span><span class="n">add_signal_handler</span><span class="p">(</span>
<span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> <span class="k">lambda</span><span class="p">:</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">handle_signal</span><span class="p">(</span><span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">))</span>
<span class="p">)</span>
Expand Down Expand Up @@ -143,18 +153,25 @@ <h1>Source code for chaturbate_poller.signal_handler</h1><div class="highlight">
<div class="viewcode-block" id="SignalHandler._cancel_tasks">
<a class="viewcode-back" href="../../autoapi/chaturbate_poller/signal_handler/index.html#chaturbate_poller.signal_handler.SignalHandler._cancel_tasks">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">_cancel_tasks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Cancel all running tasks except the current one.&quot;&quot;&quot;</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Cancel all running tasks except the current one.</span>

<span class="sd"> Logs any exceptions during cancellation and enforces a timeout.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">current_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">current_task</span><span class="p">()</span>
<span class="n">tasks</span> <span class="o">=</span> <span class="p">[</span><span class="n">task</span> <span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">all_tasks</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">loop</span><span class="p">)</span> <span class="k">if</span> <span class="n">task</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">current_task</span><span class="p">]</span>
<span class="n">tasks</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">asyncio</span><span class="o">.</span><span class="n">Task</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">task</span> <span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">all_tasks</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">loop</span><span class="p">)</span> <span class="k">if</span> <span class="n">task</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">current_task</span>
<span class="p">]</span>

<span class="k">if</span> <span class="n">tasks</span><span class="p">:</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Cancelling </span><span class="si">%s</span><span class="s2"> running task(s)...&quot;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">tasks</span><span class="p">))</span>
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="n">tasks</span><span class="p">:</span>
<span class="n">task</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>

<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="o">*</span><span class="n">tasks</span><span class="p">,</span> <span class="n">return_exceptions</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;All tasks cancelled and cleaned up.&quot;</span><span class="p">)</span></div>
<span class="k">try</span><span class="p">:</span>
<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">wait</span><span class="p">(</span><span class="n">tasks</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mf">5.0</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;All tasks cancelled successfully.&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">TimeoutError</span><span class="p">:</span>
<span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">&quot;Timeout reached while cancelling tasks.&quot;</span><span class="p">)</span></div>
</div>

</pre></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ Module Contents
.. py:attribute:: stop_future
.. py:attribute:: _is_setup
:value: False



.. py:method:: setup() -> None
:async:


Set up signal handlers for SIGINT and SIGTERM asynchronously.

:raises RuntimeError: If setup is called more than once.



.. py:method:: handle_signal(sig: signal.Signals) -> None
Expand Down Expand Up @@ -78,5 +85,7 @@ Module Contents

Cancel all running tasks except the current one.

Logs any exceptions during cancellation and enforces a timeout.



11 changes: 11 additions & 0 deletions autoapi/chaturbate_poller/signal_handler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,20 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to
<span class="sig-name descname"><span class="pre">stop_future</span></span><a class="headerlink" href="#chaturbate_poller.signal_handler.SignalHandler.stop_future" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="chaturbate_poller.signal_handler.SignalHandler._is_setup">
<span class="sig-name descname"><span class="pre">_is_setup</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">False</span></em><a class="headerlink" href="#chaturbate_poller.signal_handler.SignalHandler._is_setup" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="chaturbate_poller.signal_handler.SignalHandler.setup">
<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">setup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../../../_modules/chaturbate_poller/signal_handler.html#SignalHandler.setup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#chaturbate_poller.signal_handler.SignalHandler.setup" title="Link to this definition"></a></dt>
<dd><p>Set up signal handlers for SIGINT and SIGTERM asynchronously.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> – If setup is called more than once.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
Expand All @@ -180,6 +190,7 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to
<dt class="sig sig-object py" id="chaturbate_poller.signal_handler.SignalHandler._cancel_tasks">
<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">_cancel_tasks</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../../../_modules/chaturbate_poller/signal_handler.html#SignalHandler._cancel_tasks"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#chaturbate_poller.signal_handler.SignalHandler._cancel_tasks" title="Link to this definition"></a></dt>
<dd><p>Cancel all running tasks except the current one.</p>
<p>Logs any exceptions during cancellation and enforces a timeout.</p>
</dd></dl>

</dd></dl>
Expand Down
2 changes: 2 additions & 0 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ <h2 id="_">_</h2>
<li><a href="autoapi/chaturbate_poller/index.html#chaturbate_poller.ChaturbateClient._construct_url">(chaturbate_poller.ChaturbateClient method)</a>
</li>
</ul></li>
<li><a href="autoapi/chaturbate_poller/signal_handler/index.html#chaturbate_poller.signal_handler.SignalHandler._is_setup">_is_setup (chaturbate_poller.signal_handler.SignalHandler attribute)</a>
</li>
<li><a href="autoapi/chaturbate_poller/signal_handler/index.html#chaturbate_poller.signal_handler.SignalHandler._shutdown">_shutdown() (chaturbate_poller.signal_handler.SignalHandler method)</a>
</li>
</ul></td>
Expand Down
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 3ad2ff4

Please sign in to comment.