Initial public upload from Projekte/PromptBoost (part 5)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/INSTALLER +1 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/METADATA +176 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/RECORD +65 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/REQUESTED +0 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/WHEEL +7 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/licenses/LICENSE-APACHE +203 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/licenses/LICENSE-MIT +21 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/top_level.txt +1 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/poll.pxd +25 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/poll.pyx +233 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/process.pxd +80 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/process.pyx +792 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/stream.pxd +50 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/stream.pyx +1016 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/streamserver.pxd +26 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/streamserver.pyx +150 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/tcp.pxd +26 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/tcp.pyx +228 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/timer.pxd +18 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/timer.pyx +89 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/udp.pxd +22 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/udp.pyx +408 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/__init__.py +23 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/consts.pxi +33 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/debug.pxd +3 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/flowcontrol.pxd +23 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/python.pxd +31 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/stdlib.pxi +176 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/system.pxd +96 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/uv.pxd +506 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.cpython-313-x86_64-linux-gnu.so +3 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pxd +230 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pyi +297 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pyx +0 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/lru.pyx +79 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/pseudosock.pyx +209 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/py.typed +0 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/request.pxd +8 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/request.pyx +65 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/server.pxd +19 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/server.pyx +136 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/sslproto.pxd +138 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/sslproto.pyx +950 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/INSTALLER +1 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/METADATA +148 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/RECORD +18 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/REQUESTED +0 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/WHEEL +4 -0
- personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/entry_points.txt +2 -0
.gitattributes
CHANGED
|
@@ -39,3 +39,7 @@ personalPromptBoost/.venv/bin/python3.13 filter=lfs diff=lfs merge=lfs -text
|
|
| 39 |
personalPromptBoost/.venv/lib/python3.13/site-packages/httptools/parser/parser.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 40 |
personalPromptBoost/.venv/lib/python3.13/site-packages/httptools/parser/url_parser.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
personalPromptBoost/.venv/lib/python3.13/site-packages/pydantic_core/_pydantic_core.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
personalPromptBoost/.venv/lib/python3.13/site-packages/httptools/parser/parser.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 40 |
personalPromptBoost/.venv/lib/python3.13/site-packages/httptools/parser/url_parser.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
personalPromptBoost/.venv/lib/python3.13/site-packages/pydantic_core/_pydantic_core.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles/_rust_notify.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
personalPromptBoost/.venv/lib/python3.13/site-packages/yaml/_yaml.cpython-313-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
personalPromptBoost/promptboost.db filter=lfs diff=lfs merge=lfs -text
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
uv
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/METADATA
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: uvloop
|
| 3 |
+
Version: 0.22.1
|
| 4 |
+
Summary: Fast implementation of asyncio event loop on top of libuv
|
| 5 |
+
Author-email: Yury Selivanov <yury@magic.io>
|
| 6 |
+
License: MIT License
|
| 7 |
+
Project-URL: github, https://github.com/MagicStack/uvloop
|
| 8 |
+
Keywords: asyncio,networking
|
| 9 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 10 |
+
Classifier: Framework :: AsyncIO
|
| 11 |
+
Classifier: Intended Audience :: Developers
|
| 12 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 13 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 14 |
+
Classifier: Operating System :: POSIX
|
| 15 |
+
Classifier: Operating System :: MacOS :: MacOS X
|
| 16 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 23 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 24 |
+
Classifier: Topic :: System :: Networking
|
| 25 |
+
Requires-Python: >=3.8.1
|
| 26 |
+
Description-Content-Type: text/x-rst
|
| 27 |
+
License-File: LICENSE-APACHE
|
| 28 |
+
License-File: LICENSE-MIT
|
| 29 |
+
Provides-Extra: test
|
| 30 |
+
Requires-Dist: aiohttp>=3.10.5; extra == "test"
|
| 31 |
+
Requires-Dist: flake8~=6.1; extra == "test"
|
| 32 |
+
Requires-Dist: psutil; extra == "test"
|
| 33 |
+
Requires-Dist: pycodestyle~=2.11.0; extra == "test"
|
| 34 |
+
Requires-Dist: pyOpenSSL~=25.3.0; extra == "test"
|
| 35 |
+
Requires-Dist: mypy>=0.800; extra == "test"
|
| 36 |
+
Provides-Extra: dev
|
| 37 |
+
Requires-Dist: setuptools>=60; extra == "dev"
|
| 38 |
+
Requires-Dist: Cython~=3.0; extra == "dev"
|
| 39 |
+
Provides-Extra: docs
|
| 40 |
+
Requires-Dist: Sphinx~=4.1.2; extra == "docs"
|
| 41 |
+
Requires-Dist: sphinxcontrib-asyncio~=0.3.0; extra == "docs"
|
| 42 |
+
Requires-Dist: sphinx_rtd_theme~=0.5.2; extra == "docs"
|
| 43 |
+
Dynamic: license-file
|
| 44 |
+
|
| 45 |
+
.. image:: https://img.shields.io/github/actions/workflow/status/MagicStack/uvloop/tests.yml?branch=master
|
| 46 |
+
:target: https://github.com/MagicStack/uvloop/actions/workflows/tests.yml?query=branch%3Amaster
|
| 47 |
+
|
| 48 |
+
.. image:: https://img.shields.io/pypi/v/uvloop.svg
|
| 49 |
+
:target: https://pypi.python.org/pypi/uvloop
|
| 50 |
+
|
| 51 |
+
.. image:: https://pepy.tech/badge/uvloop
|
| 52 |
+
:target: https://pepy.tech/project/uvloop
|
| 53 |
+
:alt: PyPI - Downloads
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
uvloop is a fast, drop-in replacement of the built-in asyncio
|
| 57 |
+
event loop. uvloop is implemented in Cython and uses libuv
|
| 58 |
+
under the hood.
|
| 59 |
+
|
| 60 |
+
The project documentation can be found
|
| 61 |
+
`here <http://uvloop.readthedocs.org/>`_. Please also check out the
|
| 62 |
+
`wiki <https://github.com/MagicStack/uvloop/wiki>`_.
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
Performance
|
| 66 |
+
-----------
|
| 67 |
+
|
| 68 |
+
uvloop makes asyncio 2-4x faster.
|
| 69 |
+
|
| 70 |
+
.. image:: https://raw.githubusercontent.com/MagicStack/uvloop/master/performance.png
|
| 71 |
+
:target: http://magic.io/blog/uvloop-blazing-fast-python-networking/
|
| 72 |
+
|
| 73 |
+
The above chart shows the performance of an echo server with different
|
| 74 |
+
message sizes. The *sockets* benchmark uses ``loop.sock_recv()`` and
|
| 75 |
+
``loop.sock_sendall()`` methods; the *streams* benchmark uses asyncio
|
| 76 |
+
high-level streams, created by the ``asyncio.start_server()`` function;
|
| 77 |
+
and the *protocol* benchmark uses ``loop.create_server()`` with a simple
|
| 78 |
+
echo protocol. Read more about uvloop in a
|
| 79 |
+
`blog post <http://magic.io/blog/uvloop-blazing-fast-python-networking/>`_
|
| 80 |
+
about it.
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
Installation
|
| 84 |
+
------------
|
| 85 |
+
|
| 86 |
+
uvloop requires Python 3.8 or greater and is available on PyPI.
|
| 87 |
+
Use pip to install it::
|
| 88 |
+
|
| 89 |
+
$ pip install uvloop
|
| 90 |
+
|
| 91 |
+
Note that it is highly recommended to **upgrade pip before** installing
|
| 92 |
+
uvloop with::
|
| 93 |
+
|
| 94 |
+
$ pip install -U pip
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
Using uvloop
|
| 98 |
+
------------
|
| 99 |
+
|
| 100 |
+
As of uvloop 0.18, the preferred way of using it is via the
|
| 101 |
+
``uvloop.run()`` helper function:
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
.. code:: python
|
| 105 |
+
|
| 106 |
+
import uvloop
|
| 107 |
+
|
| 108 |
+
async def main():
|
| 109 |
+
# Main entry-point.
|
| 110 |
+
...
|
| 111 |
+
|
| 112 |
+
uvloop.run(main())
|
| 113 |
+
|
| 114 |
+
``uvloop.run()`` works by simply configuring ``asyncio.run()``
|
| 115 |
+
to use uvloop, passing all of the arguments to it, such as ``debug``,
|
| 116 |
+
e.g. ``uvloop.run(main(), debug=True)``.
|
| 117 |
+
|
| 118 |
+
With Python 3.11 and earlier the following alternative
|
| 119 |
+
snippet can be used:
|
| 120 |
+
|
| 121 |
+
.. code:: python
|
| 122 |
+
|
| 123 |
+
import asyncio
|
| 124 |
+
import sys
|
| 125 |
+
|
| 126 |
+
import uvloop
|
| 127 |
+
|
| 128 |
+
async def main():
|
| 129 |
+
# Main entry-point.
|
| 130 |
+
...
|
| 131 |
+
|
| 132 |
+
if sys.version_info >= (3, 11):
|
| 133 |
+
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
|
| 134 |
+
runner.run(main())
|
| 135 |
+
else:
|
| 136 |
+
uvloop.install()
|
| 137 |
+
asyncio.run(main())
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
Building From Source
|
| 141 |
+
--------------------
|
| 142 |
+
|
| 143 |
+
To build uvloop, you'll need Python 3.8 or greater:
|
| 144 |
+
|
| 145 |
+
1. Clone the repository:
|
| 146 |
+
|
| 147 |
+
.. code::
|
| 148 |
+
|
| 149 |
+
$ git clone --recursive git@github.com:MagicStack/uvloop.git
|
| 150 |
+
$ cd uvloop
|
| 151 |
+
|
| 152 |
+
2. Create a virtual environment and activate it:
|
| 153 |
+
|
| 154 |
+
.. code::
|
| 155 |
+
|
| 156 |
+
$ python3 -m venv uvloop-dev
|
| 157 |
+
$ source uvloop-dev/bin/activate
|
| 158 |
+
|
| 159 |
+
3. Install development dependencies:
|
| 160 |
+
|
| 161 |
+
.. code::
|
| 162 |
+
|
| 163 |
+
$ pip install -e .[dev]
|
| 164 |
+
|
| 165 |
+
4. Build and run tests:
|
| 166 |
+
|
| 167 |
+
.. code::
|
| 168 |
+
|
| 169 |
+
$ make
|
| 170 |
+
$ make test
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
License
|
| 174 |
+
-------
|
| 175 |
+
|
| 176 |
+
uvloop is dual-licensed under MIT and Apache 2.0 licenses.
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uvloop-0.22.1.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
|
| 2 |
+
uvloop-0.22.1.dist-info/METADATA,sha256=cQYyjalnB3bDWIApcbfcQcC4btNnO_nMTA1eEf8vNYM,4922
|
| 3 |
+
uvloop-0.22.1.dist-info/RECORD,,
|
| 4 |
+
uvloop-0.22.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 5 |
+
uvloop-0.22.1.dist-info/WHEEL,sha256=2iHh9e2o6T3nHtu_NVT7Cs7pebIqF94rZK8zrQfgoJI,190
|
| 6 |
+
uvloop-0.22.1.dist-info/licenses/LICENSE-APACHE,sha256=N3AlKHeY-dzYGeH4JvpfxeLzglKGkasFKMXPjIwoLCc,11439
|
| 7 |
+
uvloop-0.22.1.dist-info/licenses/LICENSE-MIT,sha256=bdTDmfJt4EPXeirX4x20y1vwjqg2iwpC1uFYY1zIq2I,1105
|
| 8 |
+
uvloop-0.22.1.dist-info/top_level.txt,sha256=2cDaltyemYfQErB19s2jFmumeJRnbsZPJ7Lj9A78c6Y,7
|
| 9 |
+
uvloop/__init__.py,sha256=Hbbp9hfJbfrO-EtcpdNikAF3dS5BEwaQ5fVLjqGUn4M,7558
|
| 10 |
+
uvloop/_noop.py,sha256=SDAJTiWhE7g3KyttbjPdliv-Uheuas-tKX4_y_nvO_Q,86
|
| 11 |
+
uvloop/_testbase.py,sha256=sRZjHR-nMHv4UZ23AkSCtgEsvgo8uOqDchFNOFViiRg,15570
|
| 12 |
+
uvloop/_version.py,sha256=iDygi5_yOhbJ00scPU2IIWprHVl9g5IQeB7bfBUhPQY,576
|
| 13 |
+
uvloop/cbhandles.pxd,sha256=gW0spS84wbfuEHuYEbRSsHiKRmb5pfDHkYZvxhTC-Vo,752
|
| 14 |
+
uvloop/cbhandles.pyx,sha256=PTQjEEN4yGloNP6lIHddNzDOFqowvGm_CvS9M6yHvc4,12298
|
| 15 |
+
uvloop/dns.pyx,sha256=oHTr36ic6u9F-VFAAv0G92KY44O3-0x3ytcOAVvGmTs,14562
|
| 16 |
+
uvloop/errors.pyx,sha256=2etYn89Th3tIsNMLl33Quc-1WkKKY7umPOVvilTzi9k,2774
|
| 17 |
+
uvloop/handles/async_.pxd,sha256=xtsWSi0A67joJU4iFp5JWzQxwNj4LCq_KMDyDDMxdec,252
|
| 18 |
+
uvloop/handles/async_.pyx,sha256=Hd_Bgi8I9uJZ20_2qUsHYYQtwq4LKtjTr3THQYKp-Sk,1516
|
| 19 |
+
uvloop/handles/basetransport.pxd,sha256=SiDD77NPthTfjXVg12gJJGM1YYKZXw4AEK9tv22jJeE,1322
|
| 20 |
+
uvloop/handles/basetransport.pyx,sha256=GtN3vdp6DDkh1g0RRPemj0r4x-Exskw-m16p_vY_E9g,9553
|
| 21 |
+
uvloop/handles/check.pxd,sha256=IufFrzdMhLRc5zAjh7Lb0lAqw-UclrYVo-UgqIs6eJ0,276
|
| 22 |
+
uvloop/handles/check.pyx,sha256=70d5oylnFnZjEJo_HBg5JYw2hE3PvkU3rhzALDEUOK8,1881
|
| 23 |
+
uvloop/handles/fsevent.pxd,sha256=YfklQ9TeikRV2QRLNPAtkEwu_3vwrsOq9cMJxFV8VgI,325
|
| 24 |
+
uvloop/handles/fsevent.pyx,sha256=RUV2-WhBo2OjXFn0N49l4th1DFZ0kdC-7YgsIZkUBoI,2823
|
| 25 |
+
uvloop/handles/handle.pxd,sha256=QPjUCObkDwvjRAZFlolF1tNXFV9-jAf22V0KweiLdOA,1189
|
| 26 |
+
uvloop/handles/handle.pyx,sha256=YOaN1fSPzo_IJA3IbG7E10pc-dbAN7y8DyGZoLgho-M,13248
|
| 27 |
+
uvloop/handles/idle.pxd,sha256=L3Gr2tuzKHWEB2NnykwjbNyexNUlckBdGFKPufn5AZU,274
|
| 28 |
+
uvloop/handles/idle.pyx,sha256=BXi_PQrgbPN2n3-QybHo0CLhW2m9N7benwSb4q7u87I,1859
|
| 29 |
+
uvloop/handles/pipe.pxd,sha256=LzsEOwptkqNa52O1Iyqhxq2d4ppzmHr0x8cMwJIZZfk,933
|
| 30 |
+
uvloop/handles/pipe.pyx,sha256=9xINAS1xZuPM87gS-QYVGwUn_4JhcqKwqJobjpHHGkM,7688
|
| 31 |
+
uvloop/handles/poll.pxd,sha256=afAR6gAx52OnmPqaHa3y41xxtIYxam1w9XoNZRxNMwU,575
|
| 32 |
+
uvloop/handles/poll.pyx,sha256=kjlhSrRyOHnH2tJJLmBtE0ePltUWTKphJ6ml8RP0Qhg,6511
|
| 33 |
+
uvloop/handles/process.pxd,sha256=FKCuQWWzDL8r0N1phlwPJ_pGGY3TZsOl5rBQP4AlgYo,2314
|
| 34 |
+
uvloop/handles/process.pyx,sha256=x89gE5JCApGshWqln-2qxYI_I262r5udmLCnBAyW--w,26919
|
| 35 |
+
uvloop/handles/stream.pxd,sha256=1BASyhG8z9HDf4ZikWPqd-hldQgGSdHl3ta-nNEnChE,1535
|
| 36 |
+
uvloop/handles/stream.pyx,sha256=r4D5qmVHbWSusAuVNQ348R-rYDaT-WbZ0iL7ZXEye_4,31791
|
| 37 |
+
uvloop/handles/streamserver.pxd,sha256=hIDDhB2RK0lnMUscDWcGl2NRkclb6AYfche77YEdaes,786
|
| 38 |
+
uvloop/handles/streamserver.pyx,sha256=quWwKo_rz4Jzq-YNLZQ7lmcBNLSzQBpf31nS64jhbrU,4632
|
| 39 |
+
uvloop/handles/tcp.pxd,sha256=xNYy-df1tK5ywK3V7a0wWno9tAA7JH-FiIQ5F0296ZM,892
|
| 40 |
+
uvloop/handles/tcp.pyx,sha256=22isLLJ9__U7Bx2ZQwWP3Mozt0DZ66aOLREW7adKGLs,7291
|
| 41 |
+
uvloop/handles/timer.pxd,sha256=VcLZBfzd9ixuxmJrE9O3YmyVO4LfMDwcG7UNpJbTu40,440
|
| 42 |
+
uvloop/handles/timer.pyx,sha256=zT35AW9Wv9H_zWa6sw7GOi4SB7HavGUobFezTFfSq6E,2416
|
| 43 |
+
uvloop/handles/udp.pxd,sha256=gQn9FH4rAiXDR_kZNqaYcNMGMzFL-T1V1G8JI6JOHU8,671
|
| 44 |
+
uvloop/handles/udp.pyx,sha256=_doWmjAsh3vPES_CLQ7j309f71qK_6YIBGKtimpjAO8,12039
|
| 45 |
+
uvloop/includes/__init__.py,sha256=-OUZ6zr6Opdw78PKsHYi1AuP74Ep7XByxyoRYOuRtgI,361
|
| 46 |
+
uvloop/includes/consts.pxi,sha256=m6K9HIUl8G3D9iOIzK0C3_chXKwIfsiq88j3VOvUuU4,843
|
| 47 |
+
uvloop/includes/debug.pxd,sha256=cCnlyp6HkhQgVF7lAQPA31wIa1n1pn6eUY_wARYh3uA,64
|
| 48 |
+
uvloop/includes/flowcontrol.pxd,sha256=7PuZtEgp4TS1Y3iNqZZInkDKI5iCylERrcLqe2ls3EY,458
|
| 49 |
+
uvloop/includes/python.pxd,sha256=SSB2FPEsEt_Aif66l-SQvFpJ3I7TrgbL4lsiu_Kyu9k,846
|
| 50 |
+
uvloop/includes/stdlib.pxi,sha256=n_ip9t_O6A7AKuCQDBGRijW6yim89xQ1QvHPI7b3pEc,6377
|
| 51 |
+
uvloop/includes/system.pxd,sha256=pbXOeZeXaDZ0b3CIFOgObE5C-cr6vhi6io-F8wLIaNQ,2186
|
| 52 |
+
uvloop/includes/uv.pxd,sha256=wkayMxCaI9RyxTb1sqkP6DdU6l_w9ql18SYAoEYSNiA,16080
|
| 53 |
+
uvloop/loop.cpython-313-x86_64-linux-gnu.so,sha256=JxMrRctd0Nnu5w101ct99-XBnpL8OLCgtqRj6pq1F6o,15743800
|
| 54 |
+
uvloop/loop.pxd,sha256=1C4lOQV6MTWmvAnL67W3CvEyBdnDNYLEtCMPTZD40s8,6224
|
| 55 |
+
uvloop/loop.pyi,sha256=xLLboc-tuzlu68RcUhghA-jjSy-mMNixiVDNY6TZueU,10504
|
| 56 |
+
uvloop/loop.pyx,sha256=ER2KPtfFAXTGByI50FvdWQexKuBOkHQc26L_JIEn06o,118650
|
| 57 |
+
uvloop/lru.pyx,sha256=nBZ4zuy4XjsdLorq-JhNS7WObcLpZWMr1OjyRvv8FaI,2279
|
| 58 |
+
uvloop/pseudosock.pyx,sha256=M3H7qMGFXE9ZZLvYwOgBl3ZcNA5OKSnZ7NUGLJA7AlA,5383
|
| 59 |
+
uvloop/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 60 |
+
uvloop/request.pxd,sha256=7yx8JlG0Hu2cv_i2QCZ_WdLlsGjI0z5eM_ueOOOgK6w,143
|
| 61 |
+
uvloop/request.pyx,sha256=6-8Dme6LoT88B5-MzvmpuLn3hGt1eZlekvQxG0x2y8s,2259
|
| 62 |
+
uvloop/server.pxd,sha256=_zRDiZMjsmlxJRo0KDzSM0xyfg2k-TzlGln54wvXC-Y,394
|
| 63 |
+
uvloop/server.pyx,sha256=6wC5vUhAHnnUs7qHOJXvRkgov38IeY8xp6w45-rCRFc,3623
|
| 64 |
+
uvloop/sslproto.pxd,sha256=fCM5XWu5ZSTDpf5_-wF2jvj77Y403yk40QOiWc0wo1s,3534
|
| 65 |
+
uvloop/sslproto.pyx,sha256=EL1fckxojYK42OCAIJ-geUoKc0uncPH1hXg50roBQ-0,35381
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/REQUESTED
ADDED
|
File without changes
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (80.9.0)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp313-cp313-manylinux_2_17_x86_64
|
| 5 |
+
Tag: cp313-cp313-manylinux2014_x86_64
|
| 6 |
+
Tag: cp313-cp313-manylinux_2_28_x86_64
|
| 7 |
+
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/licenses/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (C) 2016-present the uvloop authors and contributors.
|
| 2 |
+
|
| 3 |
+
Apache License
|
| 4 |
+
Version 2.0, January 2004
|
| 5 |
+
http://www.apache.org/licenses/
|
| 6 |
+
|
| 7 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 8 |
+
|
| 9 |
+
1. Definitions.
|
| 10 |
+
|
| 11 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 12 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 13 |
+
|
| 14 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 15 |
+
the copyright owner that is granting the License.
|
| 16 |
+
|
| 17 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 18 |
+
other entities that control, are controlled by, or are under common
|
| 19 |
+
control with that entity. For the purposes of this definition,
|
| 20 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 21 |
+
direction or management of such entity, whether by contract or
|
| 22 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 23 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 24 |
+
|
| 25 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 26 |
+
exercising permissions granted by this License.
|
| 27 |
+
|
| 28 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 29 |
+
including but not limited to software source code, documentation
|
| 30 |
+
source, and configuration files.
|
| 31 |
+
|
| 32 |
+
"Object" form shall mean any form resulting from mechanical
|
| 33 |
+
transformation or translation of a Source form, including but
|
| 34 |
+
not limited to compiled object code, generated documentation,
|
| 35 |
+
and conversions to other media types.
|
| 36 |
+
|
| 37 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 38 |
+
Object form, made available under the License, as indicated by a
|
| 39 |
+
copyright notice that is included in or attached to the work
|
| 40 |
+
(an example is provided in the Appendix below).
|
| 41 |
+
|
| 42 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 43 |
+
form, that is based on (or derived from) the Work and for which the
|
| 44 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 45 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 46 |
+
of this License, Derivative Works shall not include works that remain
|
| 47 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 48 |
+
the Work and Derivative Works thereof.
|
| 49 |
+
|
| 50 |
+
"Contribution" shall mean any work of authorship, including
|
| 51 |
+
the original version of the Work and any modifications or additions
|
| 52 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 53 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 54 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 55 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 56 |
+
means any form of electronic, verbal, or written communication sent
|
| 57 |
+
to the Licensor or its representatives, including but not limited to
|
| 58 |
+
communication on electronic mailing lists, source code control systems,
|
| 59 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 60 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 61 |
+
excluding communication that is conspicuously marked or otherwise
|
| 62 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 63 |
+
|
| 64 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 65 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 66 |
+
subsequently incorporated within the Work.
|
| 67 |
+
|
| 68 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 69 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 70 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 71 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 72 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 73 |
+
Work and such Derivative Works in Source or Object form.
|
| 74 |
+
|
| 75 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 76 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 77 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 78 |
+
(except as stated in this section) patent license to make, have made,
|
| 79 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 80 |
+
where such license applies only to those patent claims licensable
|
| 81 |
+
by such Contributor that are necessarily infringed by their
|
| 82 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 83 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 84 |
+
institute patent litigation against any entity (including a
|
| 85 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 86 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 87 |
+
or contributory patent infringement, then any patent licenses
|
| 88 |
+
granted to You under this License for that Work shall terminate
|
| 89 |
+
as of the date such litigation is filed.
|
| 90 |
+
|
| 91 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 92 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 93 |
+
modifications, and in Source or Object form, provided that You
|
| 94 |
+
meet the following conditions:
|
| 95 |
+
|
| 96 |
+
(a) You must give any other recipients of the Work or
|
| 97 |
+
Derivative Works a copy of this License; and
|
| 98 |
+
|
| 99 |
+
(b) You must cause any modified files to carry prominent notices
|
| 100 |
+
stating that You changed the files; and
|
| 101 |
+
|
| 102 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 103 |
+
that You distribute, all copyright, patent, trademark, and
|
| 104 |
+
attribution notices from the Source form of the Work,
|
| 105 |
+
excluding those notices that do not pertain to any part of
|
| 106 |
+
the Derivative Works; and
|
| 107 |
+
|
| 108 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 109 |
+
distribution, then any Derivative Works that You distribute must
|
| 110 |
+
include a readable copy of the attribution notices contained
|
| 111 |
+
within such NOTICE file, excluding those notices that do not
|
| 112 |
+
pertain to any part of the Derivative Works, in at least one
|
| 113 |
+
of the following places: within a NOTICE text file distributed
|
| 114 |
+
as part of the Derivative Works; within the Source form or
|
| 115 |
+
documentation, if provided along with the Derivative Works; or,
|
| 116 |
+
within a display generated by the Derivative Works, if and
|
| 117 |
+
wherever such third-party notices normally appear. The contents
|
| 118 |
+
of the NOTICE file are for informational purposes only and
|
| 119 |
+
do not modify the License. You may add Your own attribution
|
| 120 |
+
notices within Derivative Works that You distribute, alongside
|
| 121 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 122 |
+
that such additional attribution notices cannot be construed
|
| 123 |
+
as modifying the License.
|
| 124 |
+
|
| 125 |
+
You may add Your own copyright statement to Your modifications and
|
| 126 |
+
may provide additional or different license terms and conditions
|
| 127 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 128 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 129 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 130 |
+
the conditions stated in this License.
|
| 131 |
+
|
| 132 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 133 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 134 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 135 |
+
this License, without any additional terms or conditions.
|
| 136 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 137 |
+
the terms of any separate license agreement you may have executed
|
| 138 |
+
with Licensor regarding such Contributions.
|
| 139 |
+
|
| 140 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 141 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 142 |
+
except as required for reasonable and customary use in describing the
|
| 143 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 144 |
+
|
| 145 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 146 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 147 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 148 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 149 |
+
implied, including, without limitation, any warranties or conditions
|
| 150 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 151 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 152 |
+
appropriateness of using or redistributing the Work and assume any
|
| 153 |
+
risks associated with Your exercise of permissions under this License.
|
| 154 |
+
|
| 155 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 156 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 157 |
+
unless required by applicable law (such as deliberate and grossly
|
| 158 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 159 |
+
liable to You for damages, including any direct, indirect, special,
|
| 160 |
+
incidental, or consequential damages of any character arising as a
|
| 161 |
+
result of this License or out of the use or inability to use the
|
| 162 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 163 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 164 |
+
other commercial damages or losses), even if such Contributor
|
| 165 |
+
has been advised of the possibility of such damages.
|
| 166 |
+
|
| 167 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 168 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 169 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 170 |
+
or other liability obligations and/or rights consistent with this
|
| 171 |
+
License. However, in accepting such obligations, You may act only
|
| 172 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 173 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 174 |
+
defend, and hold each Contributor harmless for any liability
|
| 175 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 176 |
+
of your accepting any such warranty or additional liability.
|
| 177 |
+
|
| 178 |
+
END OF TERMS AND CONDITIONS
|
| 179 |
+
|
| 180 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 181 |
+
|
| 182 |
+
To apply the Apache License to your work, attach the following
|
| 183 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 184 |
+
replaced with your own identifying information. (Don't include
|
| 185 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 186 |
+
comment syntax for the file format. We also recommend that a
|
| 187 |
+
file or class name and description of purpose be included on the
|
| 188 |
+
same "printed page" as the copyright notice for easier
|
| 189 |
+
identification within third-party archives.
|
| 190 |
+
|
| 191 |
+
Copyright (c) 2015-present MagicStack Inc. http://magic.io
|
| 192 |
+
|
| 193 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 194 |
+
you may not use this file except in compliance with the License.
|
| 195 |
+
You may obtain a copy of the License at
|
| 196 |
+
|
| 197 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 198 |
+
|
| 199 |
+
Unless required by applicable law or agreed to in writing, software
|
| 200 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 202 |
+
See the License for the specific language governing permissions and
|
| 203 |
+
limitations under the License.
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/licenses/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2016-present the uvloop authors and contributors.
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop-0.22.1.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
uvloop
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/poll.pxd
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVPoll(UVHandle):
|
| 2 |
+
cdef:
|
| 3 |
+
int fd
|
| 4 |
+
Handle reading_handle
|
| 5 |
+
Handle writing_handle
|
| 6 |
+
|
| 7 |
+
cdef _init(self, Loop loop, int fd)
|
| 8 |
+
cdef _close(self)
|
| 9 |
+
|
| 10 |
+
cdef inline _poll_start(self, int flags)
|
| 11 |
+
cdef inline _poll_stop(self)
|
| 12 |
+
|
| 13 |
+
cdef int is_active(self) noexcept
|
| 14 |
+
|
| 15 |
+
cdef is_reading(self)
|
| 16 |
+
cdef is_writing(self)
|
| 17 |
+
|
| 18 |
+
cdef start_reading(self, Handle callback)
|
| 19 |
+
cdef start_writing(self, Handle callback)
|
| 20 |
+
cdef stop_reading(self)
|
| 21 |
+
cdef stop_writing(self)
|
| 22 |
+
cdef stop(self)
|
| 23 |
+
|
| 24 |
+
@static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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.no_gc_clear
|
| 2 |
+
cdef class UVPoll(UVHandle):
|
| 3 |
+
cdef _init(self, Loop loop, int fd):
|
| 4 |
+
cdef int err
|
| 5 |
+
|
| 6 |
+
self._start_init(loop)
|
| 7 |
+
|
| 8 |
+
self._handle = <uv.uv_handle_t*>PyMem_RawMalloc(sizeof(uv.uv_poll_t))
|
| 9 |
+
if self._handle is NULL:
|
| 10 |
+
self._abort_init()
|
| 11 |
+
raise MemoryError()
|
| 12 |
+
|
| 13 |
+
err = uv.uv_poll_init(self._loop.uvloop,
|
| 14 |
+
<uv.uv_poll_t *>self._handle, fd)
|
| 15 |
+
if err < 0:
|
| 16 |
+
self._abort_init()
|
| 17 |
+
raise convert_error(err)
|
| 18 |
+
|
| 19 |
+
self._finish_init()
|
| 20 |
+
|
| 21 |
+
self.fd = fd
|
| 22 |
+
self.reading_handle = None
|
| 23 |
+
self.writing_handle = None
|
| 24 |
+
|
| 25 |
+
@staticmethod
|
| 26 |
+
cdef UVPoll new(Loop loop, int fd):
|
| 27 |
+
cdef UVPoll handle
|
| 28 |
+
handle = UVPoll.__new__(UVPoll)
|
| 29 |
+
handle._init(loop, fd)
|
| 30 |
+
return handle
|
| 31 |
+
|
| 32 |
+
cdef int is_active(self) noexcept:
|
| 33 |
+
return (self.reading_handle is not None or
|
| 34 |
+
self.writing_handle is not None)
|
| 35 |
+
|
| 36 |
+
cdef inline _poll_start(self, int flags):
|
| 37 |
+
cdef int err
|
| 38 |
+
|
| 39 |
+
self._ensure_alive()
|
| 40 |
+
|
| 41 |
+
err = uv.uv_poll_start(
|
| 42 |
+
<uv.uv_poll_t*>self._handle,
|
| 43 |
+
flags,
|
| 44 |
+
__on_uvpoll_event)
|
| 45 |
+
|
| 46 |
+
if err < 0:
|
| 47 |
+
exc = convert_error(err)
|
| 48 |
+
self._fatal_error(exc, True)
|
| 49 |
+
return
|
| 50 |
+
|
| 51 |
+
cdef inline _poll_stop(self):
|
| 52 |
+
cdef int err
|
| 53 |
+
|
| 54 |
+
if not self._is_alive():
|
| 55 |
+
return
|
| 56 |
+
|
| 57 |
+
err = uv.uv_poll_stop(<uv.uv_poll_t*>self._handle)
|
| 58 |
+
if err < 0:
|
| 59 |
+
exc = convert_error(err)
|
| 60 |
+
self._fatal_error(exc, True)
|
| 61 |
+
return
|
| 62 |
+
|
| 63 |
+
cdef:
|
| 64 |
+
int backend_id
|
| 65 |
+
system.epoll_event dummy_event
|
| 66 |
+
|
| 67 |
+
if system.PLATFORM_IS_LINUX:
|
| 68 |
+
# libuv doesn't remove the FD from epoll immediately
|
| 69 |
+
# after uv_poll_stop or uv_poll_close, causing hard
|
| 70 |
+
# to debug issue with dup-ed file descriptors causing
|
| 71 |
+
# CPU burn in epoll/epoll_ctl:
|
| 72 |
+
# https://github.com/MagicStack/uvloop/issues/61
|
| 73 |
+
#
|
| 74 |
+
# It's safe though to manually call epoll_ctl here,
|
| 75 |
+
# after calling uv_poll_stop.
|
| 76 |
+
|
| 77 |
+
backend_id = uv.uv_backend_fd(self._loop.uvloop)
|
| 78 |
+
if backend_id != -1:
|
| 79 |
+
memset(&dummy_event, 0, sizeof(dummy_event))
|
| 80 |
+
system.epoll_ctl(
|
| 81 |
+
backend_id,
|
| 82 |
+
system.EPOLL_CTL_DEL,
|
| 83 |
+
self.fd,
|
| 84 |
+
&dummy_event) # ignore errors
|
| 85 |
+
|
| 86 |
+
cdef is_reading(self):
|
| 87 |
+
return self._is_alive() and self.reading_handle is not None
|
| 88 |
+
|
| 89 |
+
cdef is_writing(self):
|
| 90 |
+
return self._is_alive() and self.writing_handle is not None
|
| 91 |
+
|
| 92 |
+
cdef start_reading(self, Handle callback):
|
| 93 |
+
cdef:
|
| 94 |
+
int mask = 0
|
| 95 |
+
|
| 96 |
+
if self.reading_handle is None:
|
| 97 |
+
# not reading right now, setup the handle
|
| 98 |
+
|
| 99 |
+
mask = uv.UV_READABLE
|
| 100 |
+
if self.writing_handle is not None:
|
| 101 |
+
# are we writing right now?
|
| 102 |
+
mask |= uv.UV_WRITABLE
|
| 103 |
+
|
| 104 |
+
self._poll_start(mask)
|
| 105 |
+
else:
|
| 106 |
+
self.reading_handle._cancel()
|
| 107 |
+
|
| 108 |
+
self.reading_handle = callback
|
| 109 |
+
|
| 110 |
+
cdef start_writing(self, Handle callback):
|
| 111 |
+
cdef:
|
| 112 |
+
int mask = 0
|
| 113 |
+
|
| 114 |
+
if self.writing_handle is None:
|
| 115 |
+
# not writing right now, setup the handle
|
| 116 |
+
|
| 117 |
+
mask = uv.UV_WRITABLE
|
| 118 |
+
if self.reading_handle is not None:
|
| 119 |
+
# are we reading right now?
|
| 120 |
+
mask |= uv.UV_READABLE
|
| 121 |
+
|
| 122 |
+
self._poll_start(mask)
|
| 123 |
+
else:
|
| 124 |
+
self.writing_handle._cancel()
|
| 125 |
+
|
| 126 |
+
self.writing_handle = callback
|
| 127 |
+
|
| 128 |
+
cdef stop_reading(self):
|
| 129 |
+
if self.reading_handle is None:
|
| 130 |
+
return False
|
| 131 |
+
|
| 132 |
+
self.reading_handle._cancel()
|
| 133 |
+
self.reading_handle = None
|
| 134 |
+
|
| 135 |
+
if self.writing_handle is None:
|
| 136 |
+
self.stop()
|
| 137 |
+
else:
|
| 138 |
+
self._poll_start(uv.UV_WRITABLE)
|
| 139 |
+
|
| 140 |
+
return True
|
| 141 |
+
|
| 142 |
+
cdef stop_writing(self):
|
| 143 |
+
if self.writing_handle is None:
|
| 144 |
+
return False
|
| 145 |
+
|
| 146 |
+
self.writing_handle._cancel()
|
| 147 |
+
self.writing_handle = None
|
| 148 |
+
|
| 149 |
+
if self.reading_handle is None:
|
| 150 |
+
self.stop()
|
| 151 |
+
else:
|
| 152 |
+
self._poll_start(uv.UV_READABLE)
|
| 153 |
+
|
| 154 |
+
return True
|
| 155 |
+
|
| 156 |
+
cdef stop(self):
|
| 157 |
+
if self.reading_handle is not None:
|
| 158 |
+
self.reading_handle._cancel()
|
| 159 |
+
self.reading_handle = None
|
| 160 |
+
|
| 161 |
+
if self.writing_handle is not None:
|
| 162 |
+
self.writing_handle._cancel()
|
| 163 |
+
self.writing_handle = None
|
| 164 |
+
|
| 165 |
+
self._poll_stop()
|
| 166 |
+
|
| 167 |
+
cdef _close(self):
|
| 168 |
+
if self.is_active():
|
| 169 |
+
self.stop()
|
| 170 |
+
|
| 171 |
+
UVHandle._close(<UVHandle>self)
|
| 172 |
+
|
| 173 |
+
cdef _fatal_error(self, exc, throw, reason=None):
|
| 174 |
+
try:
|
| 175 |
+
if self.reading_handle is not None:
|
| 176 |
+
try:
|
| 177 |
+
self.reading_handle._run()
|
| 178 |
+
except BaseException as ex:
|
| 179 |
+
self._loop._handle_exception(ex)
|
| 180 |
+
self.reading_handle = None
|
| 181 |
+
|
| 182 |
+
if self.writing_handle is not None:
|
| 183 |
+
try:
|
| 184 |
+
self.writing_handle._run()
|
| 185 |
+
except BaseException as ex:
|
| 186 |
+
self._loop._handle_exception(ex)
|
| 187 |
+
self.writing_handle = None
|
| 188 |
+
|
| 189 |
+
finally:
|
| 190 |
+
self._close()
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
cdef void __on_uvpoll_event(
|
| 194 |
+
uv.uv_poll_t* handle,
|
| 195 |
+
int status,
|
| 196 |
+
int events,
|
| 197 |
+
) noexcept with gil:
|
| 198 |
+
|
| 199 |
+
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVPoll callback") == 0:
|
| 200 |
+
return
|
| 201 |
+
|
| 202 |
+
cdef:
|
| 203 |
+
UVPoll poll = <UVPoll> handle.data
|
| 204 |
+
|
| 205 |
+
if status < 0:
|
| 206 |
+
exc = convert_error(status)
|
| 207 |
+
poll._fatal_error(exc, False)
|
| 208 |
+
return
|
| 209 |
+
|
| 210 |
+
if ((events & (uv.UV_READABLE | uv.UV_DISCONNECT)) and
|
| 211 |
+
poll.reading_handle is not None):
|
| 212 |
+
|
| 213 |
+
try:
|
| 214 |
+
if UVLOOP_DEBUG:
|
| 215 |
+
poll._loop._poll_read_events_total += 1
|
| 216 |
+
poll.reading_handle._run()
|
| 217 |
+
except BaseException as ex:
|
| 218 |
+
if UVLOOP_DEBUG:
|
| 219 |
+
poll._loop._poll_read_cb_errors_total += 1
|
| 220 |
+
poll._error(ex, False)
|
| 221 |
+
# continue code execution
|
| 222 |
+
|
| 223 |
+
if ((events & (uv.UV_WRITABLE | uv.UV_DISCONNECT)) and
|
| 224 |
+
poll.writing_handle is not None):
|
| 225 |
+
|
| 226 |
+
try:
|
| 227 |
+
if UVLOOP_DEBUG:
|
| 228 |
+
poll._loop._poll_write_events_total += 1
|
| 229 |
+
poll.writing_handle._run()
|
| 230 |
+
except BaseException as ex:
|
| 231 |
+
if UVLOOP_DEBUG:
|
| 232 |
+
poll._loop._poll_write_cb_errors_total += 1
|
| 233 |
+
poll._error(ex, False)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/process.pxd
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVProcess(UVHandle):
|
| 2 |
+
cdef:
|
| 3 |
+
object _returncode
|
| 4 |
+
object _pid
|
| 5 |
+
|
| 6 |
+
object _errpipe_read
|
| 7 |
+
object _errpipe_write
|
| 8 |
+
object _preexec_fn
|
| 9 |
+
bint _restore_signals
|
| 10 |
+
|
| 11 |
+
list _fds_to_close
|
| 12 |
+
|
| 13 |
+
# Attributes used to compose uv_process_options_t:
|
| 14 |
+
uv.uv_process_options_t options
|
| 15 |
+
uv.uv_stdio_container_t[3] iocnt
|
| 16 |
+
list __env
|
| 17 |
+
char **uv_opt_env
|
| 18 |
+
list __args
|
| 19 |
+
char **uv_opt_args
|
| 20 |
+
char *uv_opt_file
|
| 21 |
+
bytes __cwd
|
| 22 |
+
|
| 23 |
+
cdef _close_process_handle(self)
|
| 24 |
+
|
| 25 |
+
cdef _init(self, Loop loop, list args, dict env, cwd,
|
| 26 |
+
start_new_session,
|
| 27 |
+
_stdin, _stdout, _stderr, pass_fds,
|
| 28 |
+
debug_flags, preexec_fn, restore_signals)
|
| 29 |
+
|
| 30 |
+
cdef _after_fork(self)
|
| 31 |
+
|
| 32 |
+
cdef char** __to_cstring_array(self, list arr)
|
| 33 |
+
cdef _init_args(self, list args)
|
| 34 |
+
cdef _init_env(self, dict env)
|
| 35 |
+
cdef _init_files(self, _stdin, _stdout, _stderr)
|
| 36 |
+
cdef _init_options(self, list args, dict env, cwd, start_new_session,
|
| 37 |
+
_stdin, _stdout, _stderr, bint force_fork)
|
| 38 |
+
|
| 39 |
+
cdef _close_after_spawn(self, int fd)
|
| 40 |
+
|
| 41 |
+
cdef _on_exit(self, int64_t exit_status, int term_signal)
|
| 42 |
+
cdef _kill(self, int signum)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
cdef class UVProcessTransport(UVProcess):
|
| 46 |
+
cdef:
|
| 47 |
+
list _exit_waiters
|
| 48 |
+
list _init_futs
|
| 49 |
+
bint _stdio_ready
|
| 50 |
+
list _pending_calls
|
| 51 |
+
object _protocol
|
| 52 |
+
bint _finished
|
| 53 |
+
|
| 54 |
+
WriteUnixTransport _stdin
|
| 55 |
+
ReadUnixTransport _stdout
|
| 56 |
+
ReadUnixTransport _stderr
|
| 57 |
+
|
| 58 |
+
object stdin_proto
|
| 59 |
+
object stdout_proto
|
| 60 |
+
object stderr_proto
|
| 61 |
+
|
| 62 |
+
cdef _file_redirect_stdio(self, int fd)
|
| 63 |
+
cdef _file_devnull(self)
|
| 64 |
+
cdef _file_inpipe(self)
|
| 65 |
+
cdef _file_outpipe(self)
|
| 66 |
+
|
| 67 |
+
cdef _check_proc(self)
|
| 68 |
+
cdef _pipe_connection_lost(self, int fd, exc)
|
| 69 |
+
cdef _pipe_data_received(self, int fd, data)
|
| 70 |
+
|
| 71 |
+
cdef _call_connection_made(self, waiter)
|
| 72 |
+
cdef _try_finish(self)
|
| 73 |
+
|
| 74 |
+
@staticmethod
|
| 75 |
+
cdef UVProcessTransport new(Loop loop, protocol, args, env, cwd,
|
| 76 |
+
start_new_session,
|
| 77 |
+
_stdin, _stdout, _stderr, pass_fds,
|
| 78 |
+
waiter,
|
| 79 |
+
debug_flags,
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.no_gc_clear
|
| 2 |
+
cdef class UVProcess(UVHandle):
|
| 3 |
+
"""Abstract class; wrapper over uv_process_t handle."""
|
| 4 |
+
|
| 5 |
+
def __cinit__(self):
|
| 6 |
+
self.uv_opt_env = NULL
|
| 7 |
+
self.uv_opt_args = NULL
|
| 8 |
+
self._returncode = None
|
| 9 |
+
self._pid = None
|
| 10 |
+
self._fds_to_close = list()
|
| 11 |
+
self._preexec_fn = None
|
| 12 |
+
self._restore_signals = True
|
| 13 |
+
self.context = Context_CopyCurrent()
|
| 14 |
+
|
| 15 |
+
cdef _close_process_handle(self):
|
| 16 |
+
# XXX: This is a workaround for a libuv bug:
|
| 17 |
+
# - https://github.com/libuv/libuv/issues/1933
|
| 18 |
+
# - https://github.com/libuv/libuv/pull/551
|
| 19 |
+
if self._handle is NULL:
|
| 20 |
+
return
|
| 21 |
+
self._handle.data = NULL
|
| 22 |
+
uv.uv_close(self._handle, __uv_close_process_handle_cb)
|
| 23 |
+
self._handle = NULL # close callback will free() the memory
|
| 24 |
+
|
| 25 |
+
cdef _init(self, Loop loop, list args, dict env,
|
| 26 |
+
cwd, start_new_session,
|
| 27 |
+
_stdin, _stdout, _stderr, # std* can be defined as macros in C
|
| 28 |
+
pass_fds, debug_flags, preexec_fn, restore_signals):
|
| 29 |
+
|
| 30 |
+
global __forking
|
| 31 |
+
global __forking_loop
|
| 32 |
+
global __forkHandler
|
| 33 |
+
|
| 34 |
+
cdef int err
|
| 35 |
+
|
| 36 |
+
self._start_init(loop)
|
| 37 |
+
|
| 38 |
+
self._handle = <uv.uv_handle_t*>PyMem_RawMalloc(
|
| 39 |
+
sizeof(uv.uv_process_t))
|
| 40 |
+
if self._handle is NULL:
|
| 41 |
+
self._abort_init()
|
| 42 |
+
raise MemoryError()
|
| 43 |
+
|
| 44 |
+
# Too early to call _finish_init, but still a lot of work to do.
|
| 45 |
+
# Let's set handle.data to NULL, so in case something goes wrong,
|
| 46 |
+
# callbacks have a chance to avoid casting *something* into UVHandle.
|
| 47 |
+
self._handle.data = NULL
|
| 48 |
+
|
| 49 |
+
force_fork = False
|
| 50 |
+
if system.PLATFORM_IS_APPLE and not (
|
| 51 |
+
preexec_fn is None
|
| 52 |
+
and not pass_fds
|
| 53 |
+
):
|
| 54 |
+
# see _execute_child() in CPython/subprocess.py
|
| 55 |
+
force_fork = True
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
self._init_options(args, env, cwd, start_new_session,
|
| 59 |
+
_stdin, _stdout, _stderr, force_fork)
|
| 60 |
+
|
| 61 |
+
restore_inheritable = set()
|
| 62 |
+
if pass_fds:
|
| 63 |
+
for fd in pass_fds:
|
| 64 |
+
if not os_get_inheritable(fd):
|
| 65 |
+
restore_inheritable.add(fd)
|
| 66 |
+
os_set_inheritable(fd, True)
|
| 67 |
+
except Exception:
|
| 68 |
+
self._abort_init()
|
| 69 |
+
raise
|
| 70 |
+
|
| 71 |
+
if __forking or loop.active_process_handler is not None:
|
| 72 |
+
# Our pthread_atfork handlers won't work correctly when
|
| 73 |
+
# another loop is forking in another thread (even though
|
| 74 |
+
# GIL should help us to avoid that.)
|
| 75 |
+
self._abort_init()
|
| 76 |
+
raise RuntimeError(
|
| 77 |
+
'Racing with another loop to spawn a process.')
|
| 78 |
+
|
| 79 |
+
self._errpipe_read, self._errpipe_write = os_pipe()
|
| 80 |
+
fds_to_close = self._fds_to_close
|
| 81 |
+
self._fds_to_close = None
|
| 82 |
+
fds_to_close.append(self._errpipe_read)
|
| 83 |
+
# add the write pipe last so we can close it early
|
| 84 |
+
fds_to_close.append(self._errpipe_write)
|
| 85 |
+
try:
|
| 86 |
+
os_set_inheritable(self._errpipe_write, True)
|
| 87 |
+
|
| 88 |
+
self._preexec_fn = preexec_fn
|
| 89 |
+
self._restore_signals = restore_signals
|
| 90 |
+
|
| 91 |
+
loop.active_process_handler = self
|
| 92 |
+
__forking = 1
|
| 93 |
+
__forking_loop = loop
|
| 94 |
+
system.setForkHandler(<system.OnForkHandler>&__get_fork_handler)
|
| 95 |
+
|
| 96 |
+
PyOS_BeforeFork()
|
| 97 |
+
|
| 98 |
+
err = uv.uv_spawn(loop.uvloop,
|
| 99 |
+
<uv.uv_process_t*>self._handle,
|
| 100 |
+
&self.options)
|
| 101 |
+
|
| 102 |
+
__forking = 0
|
| 103 |
+
__forking_loop = None
|
| 104 |
+
system.resetForkHandler()
|
| 105 |
+
loop.active_process_handler = None
|
| 106 |
+
|
| 107 |
+
PyOS_AfterFork_Parent()
|
| 108 |
+
|
| 109 |
+
if err < 0:
|
| 110 |
+
self._close_process_handle()
|
| 111 |
+
self._abort_init()
|
| 112 |
+
raise convert_error(err)
|
| 113 |
+
|
| 114 |
+
self._finish_init()
|
| 115 |
+
|
| 116 |
+
# close the write pipe early
|
| 117 |
+
os_close(fds_to_close.pop())
|
| 118 |
+
|
| 119 |
+
if preexec_fn is not None:
|
| 120 |
+
errpipe_data = bytearray()
|
| 121 |
+
while True:
|
| 122 |
+
# XXX: This is a blocking code that has to be
|
| 123 |
+
# rewritten (using loop.connect_read_pipe() or
|
| 124 |
+
# otherwise.)
|
| 125 |
+
part = os_read(self._errpipe_read, 50000)
|
| 126 |
+
errpipe_data += part
|
| 127 |
+
if not part or len(errpipe_data) > 50000:
|
| 128 |
+
break
|
| 129 |
+
|
| 130 |
+
finally:
|
| 131 |
+
while fds_to_close:
|
| 132 |
+
os_close(fds_to_close.pop())
|
| 133 |
+
|
| 134 |
+
for fd in restore_inheritable:
|
| 135 |
+
os_set_inheritable(fd, False)
|
| 136 |
+
|
| 137 |
+
# asyncio caches the PID in BaseSubprocessTransport,
|
| 138 |
+
# so that the transport knows what the PID was even
|
| 139 |
+
# after the process is finished.
|
| 140 |
+
self._pid = (<uv.uv_process_t*>self._handle).pid
|
| 141 |
+
|
| 142 |
+
# Track the process handle (create a strong ref to it)
|
| 143 |
+
# to guarantee that __dealloc__ doesn't happen in an
|
| 144 |
+
# uncontrolled fashion. We want to wait until the process
|
| 145 |
+
# exits and libuv calls __uvprocess_on_exit_callback,
|
| 146 |
+
# which will call `UVProcess._close()`, which will, in turn,
|
| 147 |
+
# untrack this handle.
|
| 148 |
+
self._loop._track_process(self)
|
| 149 |
+
|
| 150 |
+
if debug_flags & __PROCESS_DEBUG_SLEEP_AFTER_FORK:
|
| 151 |
+
time_sleep(1)
|
| 152 |
+
|
| 153 |
+
if preexec_fn is not None and errpipe_data:
|
| 154 |
+
# preexec_fn has raised an exception. The child
|
| 155 |
+
# process must be dead now.
|
| 156 |
+
try:
|
| 157 |
+
exc_name, exc_msg = errpipe_data.split(b':', 1)
|
| 158 |
+
exc_name = exc_name.decode()
|
| 159 |
+
exc_msg = exc_msg.decode()
|
| 160 |
+
except Exception:
|
| 161 |
+
self._close()
|
| 162 |
+
raise subprocess_SubprocessError(
|
| 163 |
+
'Bad exception data from child: {!r}'.format(
|
| 164 |
+
errpipe_data))
|
| 165 |
+
exc_cls = getattr(__builtins__, exc_name,
|
| 166 |
+
subprocess_SubprocessError)
|
| 167 |
+
|
| 168 |
+
exc = subprocess_SubprocessError(
|
| 169 |
+
'Exception occurred in preexec_fn.')
|
| 170 |
+
exc.__cause__ = exc_cls(exc_msg)
|
| 171 |
+
self._close()
|
| 172 |
+
raise exc
|
| 173 |
+
|
| 174 |
+
cdef _after_fork(self):
|
| 175 |
+
# See CPython/_posixsubprocess.c for details
|
| 176 |
+
cdef int err
|
| 177 |
+
|
| 178 |
+
if self._restore_signals:
|
| 179 |
+
_Py_RestoreSignals()
|
| 180 |
+
|
| 181 |
+
PyOS_AfterFork_Child()
|
| 182 |
+
|
| 183 |
+
err = uv.uv_loop_fork(self._loop.uvloop)
|
| 184 |
+
if err < 0:
|
| 185 |
+
raise convert_error(err)
|
| 186 |
+
|
| 187 |
+
if self._preexec_fn is not None:
|
| 188 |
+
try:
|
| 189 |
+
gc_disable()
|
| 190 |
+
self._preexec_fn()
|
| 191 |
+
except BaseException as ex:
|
| 192 |
+
try:
|
| 193 |
+
with open(self._errpipe_write, 'wb') as f:
|
| 194 |
+
f.write(str(ex.__class__.__name__).encode())
|
| 195 |
+
f.write(b':')
|
| 196 |
+
f.write(str(ex.args[0]).encode())
|
| 197 |
+
finally:
|
| 198 |
+
system._exit(255)
|
| 199 |
+
return
|
| 200 |
+
else:
|
| 201 |
+
os_close(self._errpipe_write)
|
| 202 |
+
else:
|
| 203 |
+
os_close(self._errpipe_write)
|
| 204 |
+
|
| 205 |
+
cdef _close_after_spawn(self, int fd):
|
| 206 |
+
if self._fds_to_close is None:
|
| 207 |
+
raise RuntimeError(
|
| 208 |
+
'UVProcess._close_after_spawn called after uv_spawn')
|
| 209 |
+
self._fds_to_close.append(fd)
|
| 210 |
+
|
| 211 |
+
def __dealloc__(self):
|
| 212 |
+
if self.uv_opt_env is not NULL:
|
| 213 |
+
PyMem_RawFree(self.uv_opt_env)
|
| 214 |
+
self.uv_opt_env = NULL
|
| 215 |
+
|
| 216 |
+
if self.uv_opt_args is not NULL:
|
| 217 |
+
PyMem_RawFree(self.uv_opt_args)
|
| 218 |
+
self.uv_opt_args = NULL
|
| 219 |
+
|
| 220 |
+
cdef char** __to_cstring_array(self, list arr):
|
| 221 |
+
cdef:
|
| 222 |
+
int i
|
| 223 |
+
ssize_t arr_len = len(arr)
|
| 224 |
+
bytes el
|
| 225 |
+
|
| 226 |
+
char **ret
|
| 227 |
+
|
| 228 |
+
ret = <char **>PyMem_RawMalloc((arr_len + 1) * sizeof(char *))
|
| 229 |
+
if ret is NULL:
|
| 230 |
+
raise MemoryError()
|
| 231 |
+
|
| 232 |
+
for i in range(arr_len):
|
| 233 |
+
el = arr[i]
|
| 234 |
+
# NB: PyBytes_AsString doesn't copy the data;
|
| 235 |
+
# we have to be careful when the "arr" is GCed,
|
| 236 |
+
# and it shouldn't be ever mutated.
|
| 237 |
+
ret[i] = PyBytes_AsString(el)
|
| 238 |
+
|
| 239 |
+
ret[arr_len] = NULL
|
| 240 |
+
return ret
|
| 241 |
+
|
| 242 |
+
cdef _init_options(self, list args, dict env, cwd, start_new_session,
|
| 243 |
+
_stdin, _stdout, _stderr, bint force_fork):
|
| 244 |
+
|
| 245 |
+
memset(&self.options, 0, sizeof(uv.uv_process_options_t))
|
| 246 |
+
|
| 247 |
+
self._init_env(env)
|
| 248 |
+
self.options.env = self.uv_opt_env
|
| 249 |
+
|
| 250 |
+
self._init_args(args)
|
| 251 |
+
self.options.file = self.uv_opt_file
|
| 252 |
+
self.options.args = self.uv_opt_args
|
| 253 |
+
|
| 254 |
+
if start_new_session:
|
| 255 |
+
self.options.flags |= uv.UV_PROCESS_DETACHED
|
| 256 |
+
|
| 257 |
+
if force_fork:
|
| 258 |
+
# This is a hack to work around the change in libuv 1.44:
|
| 259 |
+
# > macos: use posix_spawn instead of fork
|
| 260 |
+
# where Python subprocess options like preexec_fn are
|
| 261 |
+
# crippled. CPython only uses posix_spawn under a pretty
|
| 262 |
+
# strict list of conditions (see subprocess.py), and falls
|
| 263 |
+
# back to using fork() otherwise. We'd like to simulate such
|
| 264 |
+
# behavior with libuv, but unfortunately libuv doesn't
|
| 265 |
+
# provide explicit API to choose such implementation detail.
|
| 266 |
+
# Based on current (libuv 1.46) behavior, setting
|
| 267 |
+
# UV_PROCESS_SETUID or UV_PROCESS_SETGID would reliably make
|
| 268 |
+
# libuv fallback to use fork, so let's just use it for now.
|
| 269 |
+
self.options.flags |= uv.UV_PROCESS_SETUID
|
| 270 |
+
self.options.uid = uv.getuid()
|
| 271 |
+
|
| 272 |
+
if cwd is not None:
|
| 273 |
+
cwd = os_fspath(cwd)
|
| 274 |
+
|
| 275 |
+
if isinstance(cwd, str):
|
| 276 |
+
cwd = PyUnicode_EncodeFSDefault(cwd)
|
| 277 |
+
if not isinstance(cwd, bytes):
|
| 278 |
+
raise ValueError('cwd must be a str or bytes object')
|
| 279 |
+
|
| 280 |
+
self.__cwd = cwd
|
| 281 |
+
self.options.cwd = PyBytes_AsString(self.__cwd)
|
| 282 |
+
|
| 283 |
+
self.options.exit_cb = &__uvprocess_on_exit_callback
|
| 284 |
+
|
| 285 |
+
self._init_files(_stdin, _stdout, _stderr)
|
| 286 |
+
|
| 287 |
+
cdef _init_args(self, list args):
|
| 288 |
+
cdef:
|
| 289 |
+
bytes path
|
| 290 |
+
int an = len(args)
|
| 291 |
+
|
| 292 |
+
if an < 1:
|
| 293 |
+
raise ValueError('cannot spawn a process: args are empty')
|
| 294 |
+
|
| 295 |
+
self.__args = args.copy()
|
| 296 |
+
for i in range(an):
|
| 297 |
+
arg = os_fspath(args[i])
|
| 298 |
+
if isinstance(arg, str):
|
| 299 |
+
self.__args[i] = PyUnicode_EncodeFSDefault(arg)
|
| 300 |
+
elif not isinstance(arg, bytes):
|
| 301 |
+
raise TypeError('all args must be str or bytes')
|
| 302 |
+
|
| 303 |
+
path = self.__args[0]
|
| 304 |
+
self.uv_opt_file = PyBytes_AsString(path)
|
| 305 |
+
self.uv_opt_args = self.__to_cstring_array(self.__args)
|
| 306 |
+
|
| 307 |
+
cdef _init_env(self, dict env):
|
| 308 |
+
if env is not None:
|
| 309 |
+
self.__env = list()
|
| 310 |
+
for key in env:
|
| 311 |
+
val = env[key]
|
| 312 |
+
|
| 313 |
+
if isinstance(key, str):
|
| 314 |
+
key = PyUnicode_EncodeFSDefault(key)
|
| 315 |
+
elif not isinstance(key, bytes):
|
| 316 |
+
raise TypeError(
|
| 317 |
+
'all environment vars must be bytes or str')
|
| 318 |
+
|
| 319 |
+
if isinstance(val, str):
|
| 320 |
+
val = PyUnicode_EncodeFSDefault(val)
|
| 321 |
+
elif not isinstance(val, bytes):
|
| 322 |
+
raise TypeError(
|
| 323 |
+
'all environment values must be bytes or str')
|
| 324 |
+
|
| 325 |
+
self.__env.append(key + b'=' + val)
|
| 326 |
+
|
| 327 |
+
self.uv_opt_env = self.__to_cstring_array(self.__env)
|
| 328 |
+
else:
|
| 329 |
+
self.__env = None
|
| 330 |
+
|
| 331 |
+
cdef _init_files(self, _stdin, _stdout, _stderr):
|
| 332 |
+
self.options.stdio_count = 0
|
| 333 |
+
|
| 334 |
+
cdef _kill(self, int signum):
|
| 335 |
+
cdef int err
|
| 336 |
+
self._ensure_alive()
|
| 337 |
+
err = uv.uv_process_kill(<uv.uv_process_t*>self._handle, signum)
|
| 338 |
+
if err < 0:
|
| 339 |
+
raise convert_error(err)
|
| 340 |
+
|
| 341 |
+
cdef _on_exit(self, int64_t exit_status, int term_signal):
|
| 342 |
+
if term_signal:
|
| 343 |
+
# From Python docs:
|
| 344 |
+
# A negative value -N indicates that the child was
|
| 345 |
+
# terminated by signal N (POSIX only).
|
| 346 |
+
self._returncode = -term_signal
|
| 347 |
+
else:
|
| 348 |
+
self._returncode = exit_status
|
| 349 |
+
|
| 350 |
+
self._close()
|
| 351 |
+
|
| 352 |
+
cdef _close(self):
|
| 353 |
+
try:
|
| 354 |
+
if self._loop is not None:
|
| 355 |
+
self._loop._untrack_process(self)
|
| 356 |
+
finally:
|
| 357 |
+
UVHandle._close(self)
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
DEF _CALL_PIPE_DATA_RECEIVED = 0
|
| 361 |
+
DEF _CALL_PIPE_CONNECTION_LOST = 1
|
| 362 |
+
DEF _CALL_PROCESS_EXITED = 2
|
| 363 |
+
DEF _CALL_CONNECTION_LOST = 3
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
@cython.no_gc_clear
|
| 367 |
+
cdef class UVProcessTransport(UVProcess):
|
| 368 |
+
def __cinit__(self):
|
| 369 |
+
self._exit_waiters = []
|
| 370 |
+
self._protocol = None
|
| 371 |
+
|
| 372 |
+
self._init_futs = []
|
| 373 |
+
self._pending_calls = []
|
| 374 |
+
self._stdio_ready = 0
|
| 375 |
+
|
| 376 |
+
self._stdin = self._stdout = self._stderr = None
|
| 377 |
+
self.stdin_proto = self.stdout_proto = self.stderr_proto = None
|
| 378 |
+
|
| 379 |
+
self._finished = 0
|
| 380 |
+
|
| 381 |
+
cdef _on_exit(self, int64_t exit_status, int term_signal):
|
| 382 |
+
UVProcess._on_exit(self, exit_status, term_signal)
|
| 383 |
+
|
| 384 |
+
if self._stdio_ready:
|
| 385 |
+
self._loop.call_soon(self._protocol.process_exited,
|
| 386 |
+
context=self.context)
|
| 387 |
+
else:
|
| 388 |
+
self._pending_calls.append((_CALL_PROCESS_EXITED, None, None))
|
| 389 |
+
|
| 390 |
+
self._try_finish()
|
| 391 |
+
|
| 392 |
+
for waiter in self._exit_waiters:
|
| 393 |
+
if not waiter.cancelled():
|
| 394 |
+
waiter.set_result(self._returncode)
|
| 395 |
+
self._exit_waiters.clear()
|
| 396 |
+
|
| 397 |
+
self._close()
|
| 398 |
+
|
| 399 |
+
cdef _check_proc(self):
|
| 400 |
+
if not self._is_alive() or self._returncode is not None:
|
| 401 |
+
raise ProcessLookupError()
|
| 402 |
+
|
| 403 |
+
cdef _pipe_connection_lost(self, int fd, exc):
|
| 404 |
+
if self._stdio_ready:
|
| 405 |
+
self._loop.call_soon(self._protocol.pipe_connection_lost, fd, exc,
|
| 406 |
+
context=self.context)
|
| 407 |
+
self._try_finish()
|
| 408 |
+
else:
|
| 409 |
+
self._pending_calls.append((_CALL_PIPE_CONNECTION_LOST, fd, exc))
|
| 410 |
+
|
| 411 |
+
cdef _pipe_data_received(self, int fd, data):
|
| 412 |
+
if self._stdio_ready:
|
| 413 |
+
self._loop.call_soon(self._protocol.pipe_data_received, fd, data,
|
| 414 |
+
context=self.context)
|
| 415 |
+
else:
|
| 416 |
+
self._pending_calls.append((_CALL_PIPE_DATA_RECEIVED, fd, data))
|
| 417 |
+
|
| 418 |
+
cdef _file_redirect_stdio(self, int fd):
|
| 419 |
+
fd = os_dup(fd)
|
| 420 |
+
os_set_inheritable(fd, True)
|
| 421 |
+
self._close_after_spawn(fd)
|
| 422 |
+
return fd
|
| 423 |
+
|
| 424 |
+
cdef _file_devnull(self):
|
| 425 |
+
dn = os_open(os_devnull, os_O_RDWR)
|
| 426 |
+
os_set_inheritable(dn, True)
|
| 427 |
+
self._close_after_spawn(dn)
|
| 428 |
+
return dn
|
| 429 |
+
|
| 430 |
+
cdef _file_outpipe(self):
|
| 431 |
+
r, w = __socketpair()
|
| 432 |
+
os_set_inheritable(w, True)
|
| 433 |
+
self._close_after_spawn(w)
|
| 434 |
+
return r, w
|
| 435 |
+
|
| 436 |
+
cdef _file_inpipe(self):
|
| 437 |
+
r, w = __socketpair()
|
| 438 |
+
os_set_inheritable(r, True)
|
| 439 |
+
self._close_after_spawn(r)
|
| 440 |
+
return r, w
|
| 441 |
+
|
| 442 |
+
cdef _init_files(self, _stdin, _stdout, _stderr):
|
| 443 |
+
cdef uv.uv_stdio_container_t *iocnt
|
| 444 |
+
|
| 445 |
+
UVProcess._init_files(self, _stdin, _stdout, _stderr)
|
| 446 |
+
|
| 447 |
+
io = [None, None, None]
|
| 448 |
+
|
| 449 |
+
self.options.stdio_count = 3
|
| 450 |
+
self.options.stdio = self.iocnt
|
| 451 |
+
|
| 452 |
+
if _stdin is not None:
|
| 453 |
+
if _stdin == subprocess_PIPE:
|
| 454 |
+
r, w = self._file_inpipe()
|
| 455 |
+
io[0] = r
|
| 456 |
+
|
| 457 |
+
self.stdin_proto = WriteSubprocessPipeProto(self, 0)
|
| 458 |
+
waiter = self._loop._new_future()
|
| 459 |
+
self._stdin = WriteUnixTransport.new(
|
| 460 |
+
self._loop, self.stdin_proto, None, waiter)
|
| 461 |
+
self._init_futs.append(waiter)
|
| 462 |
+
self._stdin._open(w)
|
| 463 |
+
self._stdin._init_protocol()
|
| 464 |
+
elif _stdin == subprocess_DEVNULL:
|
| 465 |
+
io[0] = self._file_devnull()
|
| 466 |
+
elif _stdout == subprocess_STDOUT:
|
| 467 |
+
raise ValueError(
|
| 468 |
+
'subprocess.STDOUT is supported only by stderr parameter')
|
| 469 |
+
else:
|
| 470 |
+
io[0] = self._file_redirect_stdio(_stdin)
|
| 471 |
+
else:
|
| 472 |
+
io[0] = self._file_redirect_stdio(0)
|
| 473 |
+
|
| 474 |
+
if _stdout is not None:
|
| 475 |
+
if _stdout == subprocess_PIPE:
|
| 476 |
+
# We can't use UV_CREATE_PIPE here, since 'stderr' might be
|
| 477 |
+
# set to 'subprocess.STDOUT', and there is no way to
|
| 478 |
+
# emulate that functionality with libuv high-level
|
| 479 |
+
# streams API. Therefore, we create pipes for stdout and
|
| 480 |
+
# stderr manually.
|
| 481 |
+
|
| 482 |
+
r, w = self._file_outpipe()
|
| 483 |
+
io[1] = w
|
| 484 |
+
|
| 485 |
+
self.stdout_proto = ReadSubprocessPipeProto(self, 1)
|
| 486 |
+
waiter = self._loop._new_future()
|
| 487 |
+
self._stdout = ReadUnixTransport.new(
|
| 488 |
+
self._loop, self.stdout_proto, None, waiter)
|
| 489 |
+
self._init_futs.append(waiter)
|
| 490 |
+
self._stdout._open(r)
|
| 491 |
+
self._stdout._init_protocol()
|
| 492 |
+
elif _stdout == subprocess_DEVNULL:
|
| 493 |
+
io[1] = self._file_devnull()
|
| 494 |
+
elif _stdout == subprocess_STDOUT:
|
| 495 |
+
raise ValueError(
|
| 496 |
+
'subprocess.STDOUT is supported only by stderr parameter')
|
| 497 |
+
else:
|
| 498 |
+
io[1] = self._file_redirect_stdio(_stdout)
|
| 499 |
+
else:
|
| 500 |
+
io[1] = self._file_redirect_stdio(1)
|
| 501 |
+
|
| 502 |
+
if _stderr is not None:
|
| 503 |
+
if _stderr == subprocess_PIPE:
|
| 504 |
+
r, w = self._file_outpipe()
|
| 505 |
+
io[2] = w
|
| 506 |
+
|
| 507 |
+
self.stderr_proto = ReadSubprocessPipeProto(self, 2)
|
| 508 |
+
waiter = self._loop._new_future()
|
| 509 |
+
self._stderr = ReadUnixTransport.new(
|
| 510 |
+
self._loop, self.stderr_proto, None, waiter)
|
| 511 |
+
self._init_futs.append(waiter)
|
| 512 |
+
self._stderr._open(r)
|
| 513 |
+
self._stderr._init_protocol()
|
| 514 |
+
elif _stderr == subprocess_STDOUT:
|
| 515 |
+
if io[1] is None:
|
| 516 |
+
# shouldn't ever happen
|
| 517 |
+
raise RuntimeError('cannot apply subprocess.STDOUT')
|
| 518 |
+
|
| 519 |
+
io[2] = self._file_redirect_stdio(io[1])
|
| 520 |
+
elif _stderr == subprocess_DEVNULL:
|
| 521 |
+
io[2] = self._file_devnull()
|
| 522 |
+
else:
|
| 523 |
+
io[2] = self._file_redirect_stdio(_stderr)
|
| 524 |
+
else:
|
| 525 |
+
io[2] = self._file_redirect_stdio(2)
|
| 526 |
+
|
| 527 |
+
assert len(io) == 3
|
| 528 |
+
for idx in range(3):
|
| 529 |
+
iocnt = &self.iocnt[idx]
|
| 530 |
+
if io[idx] is not None:
|
| 531 |
+
iocnt.flags = uv.UV_INHERIT_FD
|
| 532 |
+
iocnt.data.fd = io[idx]
|
| 533 |
+
else:
|
| 534 |
+
iocnt.flags = uv.UV_IGNORE
|
| 535 |
+
|
| 536 |
+
cdef _call_connection_made(self, waiter):
|
| 537 |
+
try:
|
| 538 |
+
# we're always called in the right context, so just call the user's
|
| 539 |
+
self._protocol.connection_made(self)
|
| 540 |
+
except (KeyboardInterrupt, SystemExit):
|
| 541 |
+
raise
|
| 542 |
+
except BaseException as ex:
|
| 543 |
+
if waiter is not None and not waiter.cancelled():
|
| 544 |
+
waiter.set_exception(ex)
|
| 545 |
+
else:
|
| 546 |
+
raise
|
| 547 |
+
else:
|
| 548 |
+
if waiter is not None and not waiter.cancelled():
|
| 549 |
+
waiter.set_result(True)
|
| 550 |
+
|
| 551 |
+
self._stdio_ready = 1
|
| 552 |
+
if self._pending_calls:
|
| 553 |
+
pending_calls = self._pending_calls.copy()
|
| 554 |
+
self._pending_calls.clear()
|
| 555 |
+
for (type, fd, arg) in pending_calls:
|
| 556 |
+
if type == _CALL_PIPE_CONNECTION_LOST:
|
| 557 |
+
self._pipe_connection_lost(fd, arg)
|
| 558 |
+
elif type == _CALL_PIPE_DATA_RECEIVED:
|
| 559 |
+
self._pipe_data_received(fd, arg)
|
| 560 |
+
elif type == _CALL_PROCESS_EXITED:
|
| 561 |
+
self._loop.call_soon(self._protocol.process_exited)
|
| 562 |
+
elif type == _CALL_CONNECTION_LOST:
|
| 563 |
+
self._loop.call_soon(self._protocol.connection_lost, None)
|
| 564 |
+
|
| 565 |
+
cdef _try_finish(self):
|
| 566 |
+
if self._returncode is None or self._finished:
|
| 567 |
+
return
|
| 568 |
+
|
| 569 |
+
if ((self.stdin_proto is None or self.stdin_proto.disconnected) and
|
| 570 |
+
(self.stdout_proto is None or
|
| 571 |
+
self.stdout_proto.disconnected) and
|
| 572 |
+
(self.stderr_proto is None or
|
| 573 |
+
self.stderr_proto.disconnected)):
|
| 574 |
+
|
| 575 |
+
self._finished = 1
|
| 576 |
+
|
| 577 |
+
if self._stdio_ready:
|
| 578 |
+
# copy self.context for simplicity
|
| 579 |
+
self._loop.call_soon(self._protocol.connection_lost, None,
|
| 580 |
+
context=self.context)
|
| 581 |
+
else:
|
| 582 |
+
self._pending_calls.append((_CALL_CONNECTION_LOST, None, None))
|
| 583 |
+
|
| 584 |
+
def __stdio_inited(self, waiter, stdio_fut):
|
| 585 |
+
exc = stdio_fut.exception()
|
| 586 |
+
if exc is not None:
|
| 587 |
+
if waiter is None:
|
| 588 |
+
raise exc
|
| 589 |
+
else:
|
| 590 |
+
waiter.set_exception(exc)
|
| 591 |
+
else:
|
| 592 |
+
self._loop._call_soon_handle(
|
| 593 |
+
new_MethodHandle1(self._loop,
|
| 594 |
+
"UVProcessTransport._call_connection_made",
|
| 595 |
+
<method1_t>self._call_connection_made,
|
| 596 |
+
None, # means to copy the current context
|
| 597 |
+
self, waiter))
|
| 598 |
+
|
| 599 |
+
@staticmethod
|
| 600 |
+
cdef UVProcessTransport new(Loop loop, protocol, args, env,
|
| 601 |
+
cwd, start_new_session,
|
| 602 |
+
_stdin, _stdout, _stderr, pass_fds,
|
| 603 |
+
waiter,
|
| 604 |
+
debug_flags,
|
| 605 |
+
preexec_fn,
|
| 606 |
+
restore_signals):
|
| 607 |
+
|
| 608 |
+
cdef UVProcessTransport handle
|
| 609 |
+
handle = UVProcessTransport.__new__(UVProcessTransport)
|
| 610 |
+
handle._protocol = protocol
|
| 611 |
+
handle._init(loop, args, env, cwd, start_new_session,
|
| 612 |
+
__process_convert_fileno(_stdin),
|
| 613 |
+
__process_convert_fileno(_stdout),
|
| 614 |
+
__process_convert_fileno(_stderr),
|
| 615 |
+
pass_fds,
|
| 616 |
+
debug_flags,
|
| 617 |
+
preexec_fn,
|
| 618 |
+
restore_signals)
|
| 619 |
+
|
| 620 |
+
if handle._init_futs:
|
| 621 |
+
handle._stdio_ready = 0
|
| 622 |
+
init_fut = aio_gather(*handle._init_futs)
|
| 623 |
+
# add_done_callback will copy the current context and run the
|
| 624 |
+
# callback within the context
|
| 625 |
+
init_fut.add_done_callback(
|
| 626 |
+
ft_partial(handle.__stdio_inited, waiter))
|
| 627 |
+
else:
|
| 628 |
+
handle._stdio_ready = 1
|
| 629 |
+
loop._call_soon_handle(
|
| 630 |
+
new_MethodHandle1(loop,
|
| 631 |
+
"UVProcessTransport._call_connection_made",
|
| 632 |
+
<method1_t>handle._call_connection_made,
|
| 633 |
+
None, # means to copy the current context
|
| 634 |
+
handle, waiter))
|
| 635 |
+
|
| 636 |
+
return handle
|
| 637 |
+
|
| 638 |
+
def get_protocol(self):
|
| 639 |
+
return self._protocol
|
| 640 |
+
|
| 641 |
+
def set_protocol(self, protocol):
|
| 642 |
+
self._protocol = protocol
|
| 643 |
+
|
| 644 |
+
def get_pid(self):
|
| 645 |
+
return self._pid
|
| 646 |
+
|
| 647 |
+
def get_returncode(self):
|
| 648 |
+
return self._returncode
|
| 649 |
+
|
| 650 |
+
def get_pipe_transport(self, fd):
|
| 651 |
+
if fd == 0:
|
| 652 |
+
return self._stdin
|
| 653 |
+
elif fd == 1:
|
| 654 |
+
return self._stdout
|
| 655 |
+
elif fd == 2:
|
| 656 |
+
return self._stderr
|
| 657 |
+
|
| 658 |
+
def terminate(self):
|
| 659 |
+
self._check_proc()
|
| 660 |
+
self._kill(uv.SIGTERM)
|
| 661 |
+
|
| 662 |
+
def kill(self):
|
| 663 |
+
self._check_proc()
|
| 664 |
+
self._kill(uv.SIGKILL)
|
| 665 |
+
|
| 666 |
+
def send_signal(self, int signal):
|
| 667 |
+
self._check_proc()
|
| 668 |
+
self._kill(signal)
|
| 669 |
+
|
| 670 |
+
def is_closing(self):
|
| 671 |
+
return self._closed
|
| 672 |
+
|
| 673 |
+
def close(self):
|
| 674 |
+
if self._returncode is None:
|
| 675 |
+
self._kill(uv.SIGKILL)
|
| 676 |
+
|
| 677 |
+
if self._stdin is not None:
|
| 678 |
+
self._stdin.close()
|
| 679 |
+
if self._stdout is not None:
|
| 680 |
+
self._stdout.close()
|
| 681 |
+
if self._stderr is not None:
|
| 682 |
+
self._stderr.close()
|
| 683 |
+
|
| 684 |
+
if self._returncode is not None:
|
| 685 |
+
# The process is dead, just close the UV handle.
|
| 686 |
+
#
|
| 687 |
+
# (If "self._returncode is None", the process should have been
|
| 688 |
+
# killed already and we're just waiting for a SIGCHLD; after
|
| 689 |
+
# which the transport will be GC'ed and the uvhandle will be
|
| 690 |
+
# closed in UVHandle.__dealloc__.)
|
| 691 |
+
self._close()
|
| 692 |
+
|
| 693 |
+
def get_extra_info(self, name, default=None):
|
| 694 |
+
return default
|
| 695 |
+
|
| 696 |
+
def _wait(self):
|
| 697 |
+
fut = self._loop._new_future()
|
| 698 |
+
if self._returncode is not None:
|
| 699 |
+
fut.set_result(self._returncode)
|
| 700 |
+
return fut
|
| 701 |
+
|
| 702 |
+
self._exit_waiters.append(fut)
|
| 703 |
+
return fut
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
class WriteSubprocessPipeProto(aio_BaseProtocol):
|
| 707 |
+
|
| 708 |
+
def __init__(self, proc, fd):
|
| 709 |
+
if UVLOOP_DEBUG:
|
| 710 |
+
if type(proc) is not UVProcessTransport:
|
| 711 |
+
raise TypeError
|
| 712 |
+
if not isinstance(fd, int):
|
| 713 |
+
raise TypeError
|
| 714 |
+
self.proc = proc
|
| 715 |
+
self.fd = fd
|
| 716 |
+
self.pipe = None
|
| 717 |
+
self.disconnected = False
|
| 718 |
+
|
| 719 |
+
def connection_made(self, transport):
|
| 720 |
+
self.pipe = transport
|
| 721 |
+
|
| 722 |
+
def __repr__(self):
|
| 723 |
+
return ('<%s fd=%s pipe=%r>'
|
| 724 |
+
% (self.__class__.__name__, self.fd, self.pipe))
|
| 725 |
+
|
| 726 |
+
def connection_lost(self, exc):
|
| 727 |
+
self.disconnected = True
|
| 728 |
+
(<UVProcessTransport>self.proc)._pipe_connection_lost(self.fd, exc)
|
| 729 |
+
self.proc = None
|
| 730 |
+
|
| 731 |
+
def pause_writing(self):
|
| 732 |
+
(<UVProcessTransport>self.proc)._protocol.pause_writing()
|
| 733 |
+
|
| 734 |
+
def resume_writing(self):
|
| 735 |
+
(<UVProcessTransport>self.proc)._protocol.resume_writing()
|
| 736 |
+
|
| 737 |
+
|
| 738 |
+
class ReadSubprocessPipeProto(WriteSubprocessPipeProto,
|
| 739 |
+
aio_Protocol):
|
| 740 |
+
|
| 741 |
+
def data_received(self, data):
|
| 742 |
+
(<UVProcessTransport>self.proc)._pipe_data_received(self.fd, data)
|
| 743 |
+
|
| 744 |
+
|
| 745 |
+
cdef __process_convert_fileno(object obj):
|
| 746 |
+
if obj is None or isinstance(obj, int):
|
| 747 |
+
return obj
|
| 748 |
+
|
| 749 |
+
fileno = obj.fileno()
|
| 750 |
+
if not isinstance(fileno, int):
|
| 751 |
+
raise TypeError(
|
| 752 |
+
'{!r}.fileno() returned non-integer'.format(obj))
|
| 753 |
+
return fileno
|
| 754 |
+
|
| 755 |
+
|
| 756 |
+
cdef void __uvprocess_on_exit_callback(
|
| 757 |
+
uv.uv_process_t *handle,
|
| 758 |
+
int64_t exit_status,
|
| 759 |
+
int term_signal,
|
| 760 |
+
) noexcept with gil:
|
| 761 |
+
|
| 762 |
+
if __ensure_handle_data(<uv.uv_handle_t*>handle,
|
| 763 |
+
"UVProcess exit callback") == 0:
|
| 764 |
+
return
|
| 765 |
+
|
| 766 |
+
cdef UVProcess proc = <UVProcess> handle.data
|
| 767 |
+
try:
|
| 768 |
+
proc._on_exit(exit_status, term_signal)
|
| 769 |
+
except BaseException as ex:
|
| 770 |
+
proc._error(ex, False)
|
| 771 |
+
|
| 772 |
+
|
| 773 |
+
cdef __socketpair():
|
| 774 |
+
cdef:
|
| 775 |
+
int fds[2]
|
| 776 |
+
int err
|
| 777 |
+
|
| 778 |
+
err = system.socketpair(uv.AF_UNIX, uv.SOCK_STREAM, 0, fds)
|
| 779 |
+
if err:
|
| 780 |
+
exc = convert_error(-err)
|
| 781 |
+
raise exc
|
| 782 |
+
|
| 783 |
+
os_set_inheritable(fds[0], False)
|
| 784 |
+
os_set_inheritable(fds[1], False)
|
| 785 |
+
|
| 786 |
+
return fds[0], fds[1]
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
cdef void __uv_close_process_handle_cb(
|
| 790 |
+
uv.uv_handle_t* handle
|
| 791 |
+
) noexcept with gil:
|
| 792 |
+
PyMem_RawFree(handle)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/stream.pxd
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVStream(UVBaseTransport):
|
| 2 |
+
cdef:
|
| 3 |
+
uv.uv_shutdown_t _shutdown_req
|
| 4 |
+
bint __shutting_down
|
| 5 |
+
bint __reading
|
| 6 |
+
bint __read_error_close
|
| 7 |
+
|
| 8 |
+
bint __buffered
|
| 9 |
+
object _protocol_get_buffer
|
| 10 |
+
object _protocol_buffer_updated
|
| 11 |
+
|
| 12 |
+
bint _eof
|
| 13 |
+
list _buffer
|
| 14 |
+
size_t _buffer_size
|
| 15 |
+
|
| 16 |
+
Py_buffer _read_pybuf
|
| 17 |
+
bint _read_pybuf_acquired
|
| 18 |
+
|
| 19 |
+
# All "inline" methods are final
|
| 20 |
+
|
| 21 |
+
cdef inline _init(self, Loop loop, object protocol, Server server,
|
| 22 |
+
object waiter, object context)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
cdef inline _shutdown(self)
|
| 26 |
+
cdef inline _accept(self, UVStream server)
|
| 27 |
+
|
| 28 |
+
cdef inline _close_on_read_error(self)
|
| 29 |
+
|
| 30 |
+
cdef inline __reading_started(self)
|
| 31 |
+
cdef inline __reading_stopped(self)
|
| 32 |
+
|
| 33 |
+
# The user API write() and writelines() firstly call _buffer_write() to
|
| 34 |
+
# buffer up user data chunks, potentially multiple times in writelines(),
|
| 35 |
+
# and then call _initiate_write() to start writing either immediately or in
|
| 36 |
+
# the next iteration (loop._queue_write()).
|
| 37 |
+
cdef inline _buffer_write(self, object data)
|
| 38 |
+
cdef inline _initiate_write(self)
|
| 39 |
+
|
| 40 |
+
# _exec_write() is the method that does the actual send, and _try_write()
|
| 41 |
+
# is a fast-path used in _exec_write() to send a single chunk.
|
| 42 |
+
cdef inline _exec_write(self)
|
| 43 |
+
cdef inline _try_write(self, object data)
|
| 44 |
+
|
| 45 |
+
cdef _close(self)
|
| 46 |
+
|
| 47 |
+
cdef inline _on_accept(self)
|
| 48 |
+
cdef inline _on_eof(self)
|
| 49 |
+
cdef inline _on_write(self)
|
| 50 |
+
cdef inline _on_connect(self, object exc)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/stream.pyx
ADDED
|
@@ -0,0 +1,1016 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef enum:
|
| 2 |
+
__PREALLOCED_BUFS = 4
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@cython.no_gc_clear
|
| 6 |
+
@cython.freelist(DEFAULT_FREELIST_SIZE)
|
| 7 |
+
cdef class _StreamWriteContext:
|
| 8 |
+
# used to hold additional write request information for uv_write
|
| 9 |
+
|
| 10 |
+
cdef:
|
| 11 |
+
uv.uv_write_t req
|
| 12 |
+
|
| 13 |
+
list buffers
|
| 14 |
+
|
| 15 |
+
uv.uv_buf_t uv_bufs_sml[__PREALLOCED_BUFS]
|
| 16 |
+
Py_buffer py_bufs_sml[__PREALLOCED_BUFS]
|
| 17 |
+
bint py_bufs_sml_inuse
|
| 18 |
+
|
| 19 |
+
uv.uv_buf_t* uv_bufs
|
| 20 |
+
Py_buffer* py_bufs
|
| 21 |
+
size_t py_bufs_len
|
| 22 |
+
|
| 23 |
+
uv.uv_buf_t* uv_bufs_start
|
| 24 |
+
size_t uv_bufs_len
|
| 25 |
+
|
| 26 |
+
UVStream stream
|
| 27 |
+
|
| 28 |
+
bint closed
|
| 29 |
+
|
| 30 |
+
cdef free_bufs(self):
|
| 31 |
+
cdef size_t i
|
| 32 |
+
|
| 33 |
+
if self.uv_bufs is not NULL:
|
| 34 |
+
PyMem_RawFree(self.uv_bufs)
|
| 35 |
+
self.uv_bufs = NULL
|
| 36 |
+
if UVLOOP_DEBUG:
|
| 37 |
+
if self.py_bufs_sml_inuse:
|
| 38 |
+
raise RuntimeError(
|
| 39 |
+
'_StreamWriteContext.close: uv_bufs != NULL and '
|
| 40 |
+
'py_bufs_sml_inuse is True')
|
| 41 |
+
|
| 42 |
+
if self.py_bufs is not NULL:
|
| 43 |
+
for i from 0 <= i < self.py_bufs_len:
|
| 44 |
+
PyBuffer_Release(&self.py_bufs[i])
|
| 45 |
+
PyMem_RawFree(self.py_bufs)
|
| 46 |
+
self.py_bufs = NULL
|
| 47 |
+
if UVLOOP_DEBUG:
|
| 48 |
+
if self.py_bufs_sml_inuse:
|
| 49 |
+
raise RuntimeError(
|
| 50 |
+
'_StreamWriteContext.close: py_bufs != NULL and '
|
| 51 |
+
'py_bufs_sml_inuse is True')
|
| 52 |
+
|
| 53 |
+
if self.py_bufs_sml_inuse:
|
| 54 |
+
for i from 0 <= i < self.py_bufs_len:
|
| 55 |
+
PyBuffer_Release(&self.py_bufs_sml[i])
|
| 56 |
+
self.py_bufs_sml_inuse = 0
|
| 57 |
+
|
| 58 |
+
self.py_bufs_len = 0
|
| 59 |
+
self.buffers = None
|
| 60 |
+
|
| 61 |
+
cdef close(self):
|
| 62 |
+
if self.closed:
|
| 63 |
+
return
|
| 64 |
+
self.closed = 1
|
| 65 |
+
self.free_bufs()
|
| 66 |
+
Py_DECREF(self)
|
| 67 |
+
|
| 68 |
+
cdef advance_uv_buf(self, size_t sent):
|
| 69 |
+
# Advance the pointer to first uv_buf and the
|
| 70 |
+
# pointer to first byte in that buffer.
|
| 71 |
+
#
|
| 72 |
+
# We do this after a "uv_try_write" call, which
|
| 73 |
+
# sometimes sends only a portion of data.
|
| 74 |
+
# We then call "advance_uv_buf" on the write
|
| 75 |
+
# context, and reuse it in a "uv_write" call.
|
| 76 |
+
|
| 77 |
+
cdef:
|
| 78 |
+
uv.uv_buf_t* buf
|
| 79 |
+
size_t idx
|
| 80 |
+
|
| 81 |
+
for idx from 0 <= idx < self.uv_bufs_len:
|
| 82 |
+
buf = &self.uv_bufs_start[idx]
|
| 83 |
+
if buf.len > sent:
|
| 84 |
+
buf.len -= sent
|
| 85 |
+
buf.base = buf.base + sent
|
| 86 |
+
self.uv_bufs_start = buf
|
| 87 |
+
self.uv_bufs_len -= idx
|
| 88 |
+
return
|
| 89 |
+
else:
|
| 90 |
+
sent -= self.uv_bufs_start[idx].len
|
| 91 |
+
|
| 92 |
+
if UVLOOP_DEBUG:
|
| 93 |
+
if sent < 0:
|
| 94 |
+
raise RuntimeError('fatal: sent < 0 in advance_uv_buf')
|
| 95 |
+
|
| 96 |
+
raise RuntimeError('fatal: Could not advance _StreamWriteContext')
|
| 97 |
+
|
| 98 |
+
@staticmethod
|
| 99 |
+
cdef _StreamWriteContext new(UVStream stream, list buffers):
|
| 100 |
+
cdef:
|
| 101 |
+
_StreamWriteContext ctx
|
| 102 |
+
int uv_bufs_idx = 0
|
| 103 |
+
size_t py_bufs_len = 0
|
| 104 |
+
int i
|
| 105 |
+
|
| 106 |
+
Py_buffer* p_pybufs
|
| 107 |
+
uv.uv_buf_t* p_uvbufs
|
| 108 |
+
|
| 109 |
+
ctx = _StreamWriteContext.__new__(_StreamWriteContext)
|
| 110 |
+
ctx.stream = None
|
| 111 |
+
ctx.closed = 1
|
| 112 |
+
ctx.py_bufs_len = 0
|
| 113 |
+
ctx.py_bufs_sml_inuse = 0
|
| 114 |
+
ctx.uv_bufs = NULL
|
| 115 |
+
ctx.py_bufs = NULL
|
| 116 |
+
ctx.buffers = buffers
|
| 117 |
+
ctx.stream = stream
|
| 118 |
+
|
| 119 |
+
if len(buffers) <= __PREALLOCED_BUFS:
|
| 120 |
+
# We've got a small number of buffers to write, don't
|
| 121 |
+
# need to use malloc.
|
| 122 |
+
ctx.py_bufs_sml_inuse = 1
|
| 123 |
+
p_pybufs = <Py_buffer*>&ctx.py_bufs_sml
|
| 124 |
+
p_uvbufs = <uv.uv_buf_t*>&ctx.uv_bufs_sml
|
| 125 |
+
|
| 126 |
+
else:
|
| 127 |
+
for buf in buffers:
|
| 128 |
+
if UVLOOP_DEBUG:
|
| 129 |
+
if not isinstance(buf, (bytes, bytearray, memoryview)):
|
| 130 |
+
raise RuntimeError(
|
| 131 |
+
'invalid data in writebuf: an instance of '
|
| 132 |
+
'bytes, bytearray or memoryview was expected, '
|
| 133 |
+
'got {}'.format(type(buf)))
|
| 134 |
+
|
| 135 |
+
if not PyBytes_CheckExact(buf):
|
| 136 |
+
py_bufs_len += 1
|
| 137 |
+
|
| 138 |
+
if py_bufs_len > 0:
|
| 139 |
+
ctx.py_bufs = <Py_buffer*>PyMem_RawMalloc(
|
| 140 |
+
py_bufs_len * sizeof(Py_buffer))
|
| 141 |
+
if ctx.py_bufs is NULL:
|
| 142 |
+
raise MemoryError()
|
| 143 |
+
|
| 144 |
+
ctx.uv_bufs = <uv.uv_buf_t*>PyMem_RawMalloc(
|
| 145 |
+
len(buffers) * sizeof(uv.uv_buf_t))
|
| 146 |
+
if ctx.uv_bufs is NULL:
|
| 147 |
+
raise MemoryError()
|
| 148 |
+
|
| 149 |
+
p_pybufs = ctx.py_bufs
|
| 150 |
+
p_uvbufs = ctx.uv_bufs
|
| 151 |
+
|
| 152 |
+
py_bufs_len = 0
|
| 153 |
+
for buf in buffers:
|
| 154 |
+
if PyBytes_CheckExact(buf):
|
| 155 |
+
# We can only use this hack for bytes since it's
|
| 156 |
+
# immutable. For everything else it is only safe to
|
| 157 |
+
# use buffer protocol.
|
| 158 |
+
p_uvbufs[uv_bufs_idx].base = PyBytes_AS_STRING(buf)
|
| 159 |
+
p_uvbufs[uv_bufs_idx].len = Py_SIZE(buf)
|
| 160 |
+
|
| 161 |
+
else:
|
| 162 |
+
try:
|
| 163 |
+
PyObject_GetBuffer(
|
| 164 |
+
buf, &p_pybufs[py_bufs_len], PyBUF_SIMPLE)
|
| 165 |
+
except Exception:
|
| 166 |
+
# This shouldn't ever happen, as `UVStream._buffer_write`
|
| 167 |
+
# casts non-bytes objects to `memoryviews`.
|
| 168 |
+
ctx.py_bufs_len = py_bufs_len
|
| 169 |
+
ctx.free_bufs()
|
| 170 |
+
raise
|
| 171 |
+
|
| 172 |
+
p_uvbufs[uv_bufs_idx].base = <char*>p_pybufs[py_bufs_len].buf
|
| 173 |
+
p_uvbufs[uv_bufs_idx].len = p_pybufs[py_bufs_len].len
|
| 174 |
+
|
| 175 |
+
py_bufs_len += 1
|
| 176 |
+
|
| 177 |
+
uv_bufs_idx += 1
|
| 178 |
+
|
| 179 |
+
ctx.uv_bufs_start = p_uvbufs
|
| 180 |
+
ctx.uv_bufs_len = uv_bufs_idx
|
| 181 |
+
|
| 182 |
+
ctx.py_bufs_len = py_bufs_len
|
| 183 |
+
ctx.req.data = <void*> ctx
|
| 184 |
+
|
| 185 |
+
if UVLOOP_DEBUG:
|
| 186 |
+
stream._loop._debug_stream_write_ctx_total += 1
|
| 187 |
+
stream._loop._debug_stream_write_ctx_cnt += 1
|
| 188 |
+
|
| 189 |
+
# Do incref after everything else is done.
|
| 190 |
+
# Under no circumstances we want `ctx` to be GCed while
|
| 191 |
+
# libuv is still working with `ctx.uv_bufs`.
|
| 192 |
+
Py_INCREF(ctx)
|
| 193 |
+
ctx.closed = 0
|
| 194 |
+
return ctx
|
| 195 |
+
|
| 196 |
+
def __dealloc__(self):
|
| 197 |
+
if not self.closed:
|
| 198 |
+
# Because we do an INCREF in _StreamWriteContext.new,
|
| 199 |
+
# __dealloc__ shouldn't ever happen with `self.closed == 1`
|
| 200 |
+
raise RuntimeError(
|
| 201 |
+
'open _StreamWriteContext is being deallocated')
|
| 202 |
+
|
| 203 |
+
if UVLOOP_DEBUG:
|
| 204 |
+
if self.stream is not None:
|
| 205 |
+
self.stream._loop._debug_stream_write_ctx_cnt -= 1
|
| 206 |
+
self.stream = None
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
@cython.no_gc_clear
|
| 210 |
+
cdef class UVStream(UVBaseTransport):
|
| 211 |
+
|
| 212 |
+
def __cinit__(self):
|
| 213 |
+
self.__shutting_down = 0
|
| 214 |
+
self.__reading = 0
|
| 215 |
+
self.__read_error_close = 0
|
| 216 |
+
self.__buffered = 0
|
| 217 |
+
self._eof = 0
|
| 218 |
+
self._buffer = []
|
| 219 |
+
self._buffer_size = 0
|
| 220 |
+
|
| 221 |
+
self._protocol_get_buffer = None
|
| 222 |
+
self._protocol_buffer_updated = None
|
| 223 |
+
|
| 224 |
+
self._read_pybuf_acquired = False
|
| 225 |
+
|
| 226 |
+
cdef _set_protocol(self, object protocol):
|
| 227 |
+
if protocol is None:
|
| 228 |
+
raise TypeError('protocol is required')
|
| 229 |
+
|
| 230 |
+
UVBaseTransport._set_protocol(self, protocol)
|
| 231 |
+
|
| 232 |
+
if (hasattr(protocol, 'get_buffer') and
|
| 233 |
+
not isinstance(protocol, aio_Protocol)):
|
| 234 |
+
try:
|
| 235 |
+
self._protocol_get_buffer = protocol.get_buffer
|
| 236 |
+
self._protocol_buffer_updated = protocol.buffer_updated
|
| 237 |
+
self.__buffered = 1
|
| 238 |
+
except AttributeError:
|
| 239 |
+
pass
|
| 240 |
+
else:
|
| 241 |
+
self.__buffered = 0
|
| 242 |
+
|
| 243 |
+
cdef _clear_protocol(self):
|
| 244 |
+
UVBaseTransport._clear_protocol(self)
|
| 245 |
+
self._protocol_get_buffer = None
|
| 246 |
+
self._protocol_buffer_updated = None
|
| 247 |
+
self.__buffered = 0
|
| 248 |
+
|
| 249 |
+
cdef inline _shutdown(self):
|
| 250 |
+
cdef int err
|
| 251 |
+
|
| 252 |
+
if self.__shutting_down:
|
| 253 |
+
return
|
| 254 |
+
self.__shutting_down = 1
|
| 255 |
+
|
| 256 |
+
self._ensure_alive()
|
| 257 |
+
|
| 258 |
+
self._shutdown_req.data = <void*> self
|
| 259 |
+
err = uv.uv_shutdown(&self._shutdown_req,
|
| 260 |
+
<uv.uv_stream_t*> self._handle,
|
| 261 |
+
__uv_stream_on_shutdown)
|
| 262 |
+
if err < 0:
|
| 263 |
+
exc = convert_error(err)
|
| 264 |
+
self._fatal_error(exc, True)
|
| 265 |
+
return
|
| 266 |
+
|
| 267 |
+
cdef inline _accept(self, UVStream server):
|
| 268 |
+
cdef int err
|
| 269 |
+
self._ensure_alive()
|
| 270 |
+
|
| 271 |
+
err = uv.uv_accept(<uv.uv_stream_t*>server._handle,
|
| 272 |
+
<uv.uv_stream_t*>self._handle)
|
| 273 |
+
if err < 0:
|
| 274 |
+
exc = convert_error(err)
|
| 275 |
+
self._fatal_error(exc, True)
|
| 276 |
+
return
|
| 277 |
+
|
| 278 |
+
self._on_accept()
|
| 279 |
+
|
| 280 |
+
cdef inline _close_on_read_error(self):
|
| 281 |
+
self.__read_error_close = 1
|
| 282 |
+
|
| 283 |
+
cdef bint _is_reading(self):
|
| 284 |
+
return self.__reading
|
| 285 |
+
|
| 286 |
+
cdef _start_reading(self):
|
| 287 |
+
cdef int err
|
| 288 |
+
|
| 289 |
+
if self._closing:
|
| 290 |
+
return
|
| 291 |
+
|
| 292 |
+
self._ensure_alive()
|
| 293 |
+
|
| 294 |
+
if self.__reading:
|
| 295 |
+
return
|
| 296 |
+
|
| 297 |
+
if self.__buffered:
|
| 298 |
+
err = uv.uv_read_start(<uv.uv_stream_t*>self._handle,
|
| 299 |
+
__uv_stream_buffered_alloc,
|
| 300 |
+
__uv_stream_buffered_on_read)
|
| 301 |
+
else:
|
| 302 |
+
err = uv.uv_read_start(<uv.uv_stream_t*>self._handle,
|
| 303 |
+
__loop_alloc_buffer,
|
| 304 |
+
__uv_stream_on_read)
|
| 305 |
+
if err < 0:
|
| 306 |
+
exc = convert_error(err)
|
| 307 |
+
self._fatal_error(exc, True)
|
| 308 |
+
return
|
| 309 |
+
else:
|
| 310 |
+
# UVStream must live until the read callback is called
|
| 311 |
+
self.__reading_started()
|
| 312 |
+
|
| 313 |
+
cdef inline __reading_started(self):
|
| 314 |
+
if self.__reading:
|
| 315 |
+
return
|
| 316 |
+
self.__reading = 1
|
| 317 |
+
Py_INCREF(self)
|
| 318 |
+
|
| 319 |
+
cdef inline __reading_stopped(self):
|
| 320 |
+
if not self.__reading:
|
| 321 |
+
return
|
| 322 |
+
self.__reading = 0
|
| 323 |
+
Py_DECREF(self)
|
| 324 |
+
|
| 325 |
+
cdef _stop_reading(self):
|
| 326 |
+
cdef int err
|
| 327 |
+
|
| 328 |
+
if not self.__reading:
|
| 329 |
+
return
|
| 330 |
+
|
| 331 |
+
self._ensure_alive()
|
| 332 |
+
|
| 333 |
+
# From libuv docs:
|
| 334 |
+
# This function is idempotent and may be safely
|
| 335 |
+
# called on a stopped stream.
|
| 336 |
+
err = uv.uv_read_stop(<uv.uv_stream_t*>self._handle)
|
| 337 |
+
if err < 0:
|
| 338 |
+
exc = convert_error(err)
|
| 339 |
+
self._fatal_error(exc, True)
|
| 340 |
+
return
|
| 341 |
+
else:
|
| 342 |
+
self.__reading_stopped()
|
| 343 |
+
|
| 344 |
+
cdef inline _try_write(self, object data):
|
| 345 |
+
cdef:
|
| 346 |
+
ssize_t written
|
| 347 |
+
bint used_buf = 0
|
| 348 |
+
Py_buffer py_buf
|
| 349 |
+
void* buf
|
| 350 |
+
size_t blen
|
| 351 |
+
int saved_errno
|
| 352 |
+
int fd
|
| 353 |
+
|
| 354 |
+
if (<uv.uv_stream_t*>self._handle).write_queue_size != 0:
|
| 355 |
+
raise RuntimeError(
|
| 356 |
+
'UVStream._try_write called with data in uv buffers')
|
| 357 |
+
|
| 358 |
+
if PyBytes_CheckExact(data):
|
| 359 |
+
# We can only use this hack for bytes since it's
|
| 360 |
+
# immutable. For everything else it is only safe to
|
| 361 |
+
# use buffer protocol.
|
| 362 |
+
buf = <void*>PyBytes_AS_STRING(data)
|
| 363 |
+
blen = Py_SIZE(data)
|
| 364 |
+
else:
|
| 365 |
+
PyObject_GetBuffer(data, &py_buf, PyBUF_SIMPLE)
|
| 366 |
+
used_buf = 1
|
| 367 |
+
buf = py_buf.buf
|
| 368 |
+
blen = py_buf.len
|
| 369 |
+
|
| 370 |
+
if blen == 0:
|
| 371 |
+
# Empty data, do nothing.
|
| 372 |
+
return 0
|
| 373 |
+
|
| 374 |
+
fd = self._fileno()
|
| 375 |
+
# Use `unistd.h/write` directly, it's faster than
|
| 376 |
+
# uv_try_write -- less layers of code. The error
|
| 377 |
+
# checking logic is copied from libuv.
|
| 378 |
+
written = system.write(fd, buf, blen)
|
| 379 |
+
while written == -1 and (
|
| 380 |
+
errno.errno == errno.EINTR or
|
| 381 |
+
(system.PLATFORM_IS_APPLE and
|
| 382 |
+
errno.errno == errno.EPROTOTYPE)):
|
| 383 |
+
# From libuv code (unix/stream.c):
|
| 384 |
+
# Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
|
| 385 |
+
# EPROTOTYPE can be returned while trying to write to a socket
|
| 386 |
+
# that is shutting down. If we retry the write, we should get
|
| 387 |
+
# the expected EPIPE instead.
|
| 388 |
+
written = system.write(fd, buf, blen)
|
| 389 |
+
saved_errno = errno.errno
|
| 390 |
+
|
| 391 |
+
if used_buf:
|
| 392 |
+
PyBuffer_Release(&py_buf)
|
| 393 |
+
|
| 394 |
+
if written < 0:
|
| 395 |
+
if saved_errno == errno.EAGAIN or \
|
| 396 |
+
saved_errno == system.EWOULDBLOCK:
|
| 397 |
+
return -1
|
| 398 |
+
else:
|
| 399 |
+
exc = convert_error(-saved_errno)
|
| 400 |
+
self._fatal_error(exc, True)
|
| 401 |
+
return
|
| 402 |
+
|
| 403 |
+
if UVLOOP_DEBUG:
|
| 404 |
+
self._loop._debug_stream_write_tries += 1
|
| 405 |
+
|
| 406 |
+
if <size_t>written == blen:
|
| 407 |
+
return 0
|
| 408 |
+
|
| 409 |
+
return written
|
| 410 |
+
|
| 411 |
+
cdef inline _buffer_write(self, object data):
|
| 412 |
+
cdef int dlen
|
| 413 |
+
|
| 414 |
+
if not PyBytes_CheckExact(data):
|
| 415 |
+
data = memoryview(data).cast('b')
|
| 416 |
+
|
| 417 |
+
dlen = len(data)
|
| 418 |
+
if not dlen:
|
| 419 |
+
return
|
| 420 |
+
|
| 421 |
+
self._buffer_size += dlen
|
| 422 |
+
self._buffer.append(data)
|
| 423 |
+
|
| 424 |
+
cdef inline _initiate_write(self):
|
| 425 |
+
if (not self._protocol_paused and
|
| 426 |
+
(<uv.uv_stream_t*>self._handle).write_queue_size == 0 and
|
| 427 |
+
self._buffer_size > self._high_water):
|
| 428 |
+
# Fast-path. If:
|
| 429 |
+
# - the protocol isn't yet paused,
|
| 430 |
+
# - there is no data in libuv buffers for this stream,
|
| 431 |
+
# - the protocol will be paused if we continue to buffer data
|
| 432 |
+
#
|
| 433 |
+
# Then:
|
| 434 |
+
# - Try to write all buffered data right now.
|
| 435 |
+
all_sent = self._exec_write()
|
| 436 |
+
if UVLOOP_DEBUG:
|
| 437 |
+
if self._buffer_size != 0 or self._buffer != []:
|
| 438 |
+
raise RuntimeError(
|
| 439 |
+
'_buffer_size is not 0 after a successful _exec_write')
|
| 440 |
+
|
| 441 |
+
# There is no need to call `_queue_write` anymore,
|
| 442 |
+
# as `uv_write` should be called already.
|
| 443 |
+
|
| 444 |
+
if not all_sent:
|
| 445 |
+
# If not all of the data was sent successfully,
|
| 446 |
+
# we might need to pause the protocol.
|
| 447 |
+
self._maybe_pause_protocol()
|
| 448 |
+
|
| 449 |
+
elif self._buffer_size > 0:
|
| 450 |
+
self._maybe_pause_protocol()
|
| 451 |
+
self._loop._queue_write(self)
|
| 452 |
+
|
| 453 |
+
cdef inline _exec_write(self):
|
| 454 |
+
cdef:
|
| 455 |
+
int err
|
| 456 |
+
int buf_len
|
| 457 |
+
_StreamWriteContext ctx = None
|
| 458 |
+
|
| 459 |
+
if self._closed:
|
| 460 |
+
# If the handle is closed, just return, it's too
|
| 461 |
+
# late to do anything.
|
| 462 |
+
return
|
| 463 |
+
|
| 464 |
+
buf_len = len(self._buffer)
|
| 465 |
+
if not buf_len:
|
| 466 |
+
return
|
| 467 |
+
|
| 468 |
+
if (<uv.uv_stream_t*>self._handle).write_queue_size == 0:
|
| 469 |
+
# libuv internal write buffers for this stream are empty.
|
| 470 |
+
if buf_len == 1:
|
| 471 |
+
# If we only have one piece of data to send, let's
|
| 472 |
+
# use our fast implementation of try_write.
|
| 473 |
+
data = self._buffer[0]
|
| 474 |
+
sent = self._try_write(data)
|
| 475 |
+
|
| 476 |
+
if sent is None:
|
| 477 |
+
# A `self._fatal_error` was called.
|
| 478 |
+
# It might not raise an exception under some
|
| 479 |
+
# conditions.
|
| 480 |
+
self._buffer_size = 0
|
| 481 |
+
self._buffer.clear()
|
| 482 |
+
if not self._closing:
|
| 483 |
+
# This should never happen.
|
| 484 |
+
raise RuntimeError(
|
| 485 |
+
'stream is open after UVStream._try_write '
|
| 486 |
+
'returned None')
|
| 487 |
+
return
|
| 488 |
+
|
| 489 |
+
if sent == 0:
|
| 490 |
+
# All data was successfully written.
|
| 491 |
+
self._buffer_size = 0
|
| 492 |
+
self._buffer.clear()
|
| 493 |
+
# on_write will call "maybe_resume_protocol".
|
| 494 |
+
self._on_write()
|
| 495 |
+
return True
|
| 496 |
+
|
| 497 |
+
if sent > 0:
|
| 498 |
+
if UVLOOP_DEBUG:
|
| 499 |
+
if sent == len(data):
|
| 500 |
+
raise RuntimeError(
|
| 501 |
+
'_try_write sent all data and returned '
|
| 502 |
+
'non-zero')
|
| 503 |
+
|
| 504 |
+
if PyBytes_CheckExact(data):
|
| 505 |
+
# Cast bytes to memoryview to avoid copying
|
| 506 |
+
# data that wasn't sent.
|
| 507 |
+
data = memoryview(data)
|
| 508 |
+
data = data[sent:]
|
| 509 |
+
|
| 510 |
+
self._buffer_size -= sent
|
| 511 |
+
self._buffer[0] = data
|
| 512 |
+
|
| 513 |
+
# At this point it's either data was sent partially,
|
| 514 |
+
# or an EAGAIN has happened.
|
| 515 |
+
|
| 516 |
+
else:
|
| 517 |
+
ctx = _StreamWriteContext.new(self, self._buffer)
|
| 518 |
+
|
| 519 |
+
err = uv.uv_try_write(<uv.uv_stream_t*>self._handle,
|
| 520 |
+
ctx.uv_bufs_start,
|
| 521 |
+
ctx.uv_bufs_len)
|
| 522 |
+
|
| 523 |
+
if err > 0:
|
| 524 |
+
# Some data was successfully sent.
|
| 525 |
+
|
| 526 |
+
if <size_t>err == self._buffer_size:
|
| 527 |
+
# Everything was sent.
|
| 528 |
+
ctx.close()
|
| 529 |
+
self._buffer.clear()
|
| 530 |
+
self._buffer_size = 0
|
| 531 |
+
# on_write will call "maybe_resume_protocol".
|
| 532 |
+
self._on_write()
|
| 533 |
+
return True
|
| 534 |
+
|
| 535 |
+
try:
|
| 536 |
+
# Advance pointers to uv_bufs in `ctx`,
|
| 537 |
+
# we will reuse it soon for a uv_write
|
| 538 |
+
# call.
|
| 539 |
+
ctx.advance_uv_buf(<ssize_t>err)
|
| 540 |
+
except Exception as ex: # This should never happen.
|
| 541 |
+
# Let's try to close the `ctx` anyways.
|
| 542 |
+
ctx.close()
|
| 543 |
+
self._fatal_error(ex, True)
|
| 544 |
+
self._buffer.clear()
|
| 545 |
+
self._buffer_size = 0
|
| 546 |
+
return
|
| 547 |
+
|
| 548 |
+
elif err != uv.UV_EAGAIN:
|
| 549 |
+
ctx.close()
|
| 550 |
+
exc = convert_error(err)
|
| 551 |
+
self._fatal_error(exc, True)
|
| 552 |
+
self._buffer.clear()
|
| 553 |
+
self._buffer_size = 0
|
| 554 |
+
return
|
| 555 |
+
|
| 556 |
+
# fall through
|
| 557 |
+
|
| 558 |
+
if ctx is None:
|
| 559 |
+
ctx = _StreamWriteContext.new(self, self._buffer)
|
| 560 |
+
|
| 561 |
+
err = uv.uv_write(&ctx.req,
|
| 562 |
+
<uv.uv_stream_t*>self._handle,
|
| 563 |
+
ctx.uv_bufs_start,
|
| 564 |
+
ctx.uv_bufs_len,
|
| 565 |
+
__uv_stream_on_write)
|
| 566 |
+
|
| 567 |
+
self._buffer_size = 0
|
| 568 |
+
# Can't use `_buffer.clear()` here: `ctx` holds a reference to
|
| 569 |
+
# the `_buffer`.
|
| 570 |
+
self._buffer = []
|
| 571 |
+
|
| 572 |
+
if err < 0:
|
| 573 |
+
# close write context
|
| 574 |
+
ctx.close()
|
| 575 |
+
|
| 576 |
+
exc = convert_error(err)
|
| 577 |
+
self._fatal_error(exc, True)
|
| 578 |
+
return
|
| 579 |
+
|
| 580 |
+
self._maybe_resume_protocol()
|
| 581 |
+
|
| 582 |
+
cdef size_t _get_write_buffer_size(self):
|
| 583 |
+
if self._handle is NULL:
|
| 584 |
+
return 0
|
| 585 |
+
return ((<uv.uv_stream_t*>self._handle).write_queue_size +
|
| 586 |
+
self._buffer_size)
|
| 587 |
+
|
| 588 |
+
cdef _close(self):
|
| 589 |
+
try:
|
| 590 |
+
if self._read_pybuf_acquired:
|
| 591 |
+
# Should never happen. libuv always calls uv_alloc/uv_read
|
| 592 |
+
# in pairs.
|
| 593 |
+
self._loop.call_exception_handler({
|
| 594 |
+
'transport': self,
|
| 595 |
+
'message': 'XXX: an allocated buffer in transport._close()'
|
| 596 |
+
})
|
| 597 |
+
self._read_pybuf_acquired = 0
|
| 598 |
+
PyBuffer_Release(&self._read_pybuf)
|
| 599 |
+
|
| 600 |
+
self._stop_reading()
|
| 601 |
+
finally:
|
| 602 |
+
UVSocketHandle._close(<UVHandle>self)
|
| 603 |
+
|
| 604 |
+
cdef inline _on_accept(self):
|
| 605 |
+
# Ultimately called by __uv_stream_on_listen.
|
| 606 |
+
self._init_protocol()
|
| 607 |
+
|
| 608 |
+
cdef inline _on_eof(self):
|
| 609 |
+
# Any exception raised here will be caught in
|
| 610 |
+
# __uv_stream_on_read.
|
| 611 |
+
|
| 612 |
+
try:
|
| 613 |
+
meth = self._protocol.eof_received
|
| 614 |
+
except AttributeError:
|
| 615 |
+
keep_open = False
|
| 616 |
+
else:
|
| 617 |
+
keep_open = run_in_context(self.context, meth)
|
| 618 |
+
|
| 619 |
+
if keep_open:
|
| 620 |
+
# We're keeping the connection open so the
|
| 621 |
+
# protocol can write more, but we still can't
|
| 622 |
+
# receive more, so remove the reader callback.
|
| 623 |
+
self._stop_reading()
|
| 624 |
+
else:
|
| 625 |
+
self.close()
|
| 626 |
+
|
| 627 |
+
cdef inline _on_write(self):
|
| 628 |
+
self._maybe_resume_protocol()
|
| 629 |
+
if not self._get_write_buffer_size():
|
| 630 |
+
if self._closing:
|
| 631 |
+
self._schedule_call_connection_lost(None)
|
| 632 |
+
elif self._eof:
|
| 633 |
+
self._shutdown()
|
| 634 |
+
|
| 635 |
+
cdef inline _init(self, Loop loop, object protocol, Server server,
|
| 636 |
+
object waiter, object context):
|
| 637 |
+
self.context = context
|
| 638 |
+
self._set_protocol(protocol)
|
| 639 |
+
self._start_init(loop)
|
| 640 |
+
|
| 641 |
+
if server is not None:
|
| 642 |
+
self._set_server(server)
|
| 643 |
+
|
| 644 |
+
if waiter is not None:
|
| 645 |
+
self._set_waiter(waiter)
|
| 646 |
+
|
| 647 |
+
cdef inline _on_connect(self, object exc):
|
| 648 |
+
# Called from __tcp_connect_callback (tcp.pyx) and
|
| 649 |
+
# __pipe_connect_callback (pipe.pyx).
|
| 650 |
+
if exc is None:
|
| 651 |
+
self._init_protocol()
|
| 652 |
+
else:
|
| 653 |
+
if self._waiter is None:
|
| 654 |
+
self._fatal_error(exc, False, "connect failed")
|
| 655 |
+
elif self._waiter.cancelled():
|
| 656 |
+
# Connect call was cancelled; just close the transport
|
| 657 |
+
# silently.
|
| 658 |
+
self._close()
|
| 659 |
+
elif self._waiter.done():
|
| 660 |
+
self._fatal_error(exc, False, "connect failed")
|
| 661 |
+
else:
|
| 662 |
+
self._waiter.set_exception(exc)
|
| 663 |
+
self._close()
|
| 664 |
+
|
| 665 |
+
# === Public API ===
|
| 666 |
+
|
| 667 |
+
def __repr__(self):
|
| 668 |
+
return '<{} closed={} reading={} {:#x}>'.format(
|
| 669 |
+
self.__class__.__name__,
|
| 670 |
+
self._closed,
|
| 671 |
+
self.__reading,
|
| 672 |
+
id(self))
|
| 673 |
+
|
| 674 |
+
def write(self, object buf):
|
| 675 |
+
self._ensure_alive()
|
| 676 |
+
|
| 677 |
+
if self._eof:
|
| 678 |
+
raise RuntimeError('Cannot call write() after write_eof()')
|
| 679 |
+
if not buf:
|
| 680 |
+
return
|
| 681 |
+
if self._conn_lost:
|
| 682 |
+
self._conn_lost += 1
|
| 683 |
+
return
|
| 684 |
+
self._buffer_write(buf)
|
| 685 |
+
self._initiate_write()
|
| 686 |
+
|
| 687 |
+
def writelines(self, bufs):
|
| 688 |
+
self._ensure_alive()
|
| 689 |
+
|
| 690 |
+
if self._eof:
|
| 691 |
+
raise RuntimeError('Cannot call writelines() after write_eof()')
|
| 692 |
+
if self._conn_lost:
|
| 693 |
+
self._conn_lost += 1
|
| 694 |
+
return
|
| 695 |
+
for buf in bufs:
|
| 696 |
+
self._buffer_write(buf)
|
| 697 |
+
self._initiate_write()
|
| 698 |
+
|
| 699 |
+
def write_eof(self):
|
| 700 |
+
self._ensure_alive()
|
| 701 |
+
|
| 702 |
+
if self._eof:
|
| 703 |
+
return
|
| 704 |
+
|
| 705 |
+
self._eof = 1
|
| 706 |
+
if not self._get_write_buffer_size():
|
| 707 |
+
self._shutdown()
|
| 708 |
+
|
| 709 |
+
def can_write_eof(self):
|
| 710 |
+
return True
|
| 711 |
+
|
| 712 |
+
def is_reading(self):
|
| 713 |
+
return self._is_reading()
|
| 714 |
+
|
| 715 |
+
def pause_reading(self):
|
| 716 |
+
if self._closing or not self._is_reading():
|
| 717 |
+
return
|
| 718 |
+
self._stop_reading()
|
| 719 |
+
|
| 720 |
+
def resume_reading(self):
|
| 721 |
+
if self._is_reading() or self._closing:
|
| 722 |
+
return
|
| 723 |
+
self._start_reading()
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
cdef void __uv_stream_on_shutdown(uv.uv_shutdown_t* req,
|
| 727 |
+
int status) noexcept with gil:
|
| 728 |
+
|
| 729 |
+
# callback for uv_shutdown
|
| 730 |
+
|
| 731 |
+
if req.data is NULL:
|
| 732 |
+
aio_logger.error(
|
| 733 |
+
'UVStream.shutdown callback called with NULL req.data, status=%r',
|
| 734 |
+
status)
|
| 735 |
+
return
|
| 736 |
+
|
| 737 |
+
cdef UVStream stream = <UVStream> req.data
|
| 738 |
+
|
| 739 |
+
if status < 0 and status != uv.UV_ECANCELED:
|
| 740 |
+
# From libuv source code:
|
| 741 |
+
# The ECANCELED error code is a lie, the shutdown(2) syscall is a
|
| 742 |
+
# fait accompli at this point. Maybe we should revisit this in
|
| 743 |
+
# v0.11. A possible reason for leaving it unchanged is that it
|
| 744 |
+
# informs the callee that the handle has been destroyed.
|
| 745 |
+
|
| 746 |
+
if UVLOOP_DEBUG:
|
| 747 |
+
stream._loop._debug_stream_shutdown_errors_total += 1
|
| 748 |
+
|
| 749 |
+
exc = convert_error(status)
|
| 750 |
+
stream._fatal_error(
|
| 751 |
+
exc, False, "error status in uv_stream_t.shutdown callback")
|
| 752 |
+
return
|
| 753 |
+
|
| 754 |
+
|
| 755 |
+
cdef inline bint __uv_stream_on_read_common(
|
| 756 |
+
UVStream sc,
|
| 757 |
+
Loop loop,
|
| 758 |
+
ssize_t nread,
|
| 759 |
+
):
|
| 760 |
+
if sc._closed:
|
| 761 |
+
# The stream was closed, there is no reason to
|
| 762 |
+
# do any work now.
|
| 763 |
+
sc.__reading_stopped() # Just in case.
|
| 764 |
+
return True
|
| 765 |
+
|
| 766 |
+
if nread == uv.UV_EOF:
|
| 767 |
+
# From libuv docs:
|
| 768 |
+
# The callee is responsible for stopping closing the stream
|
| 769 |
+
# when an error happens by calling uv_read_stop() or uv_close().
|
| 770 |
+
# Trying to read from the stream again is undefined.
|
| 771 |
+
try:
|
| 772 |
+
if UVLOOP_DEBUG:
|
| 773 |
+
loop._debug_stream_read_eof_total += 1
|
| 774 |
+
|
| 775 |
+
sc._stop_reading()
|
| 776 |
+
sc._on_eof()
|
| 777 |
+
except BaseException as ex:
|
| 778 |
+
if UVLOOP_DEBUG:
|
| 779 |
+
loop._debug_stream_read_eof_cb_errors_total += 1
|
| 780 |
+
|
| 781 |
+
sc._fatal_error(ex, False)
|
| 782 |
+
finally:
|
| 783 |
+
return True
|
| 784 |
+
|
| 785 |
+
if nread == 0:
|
| 786 |
+
# From libuv docs:
|
| 787 |
+
# nread might be 0, which does not indicate an error or EOF.
|
| 788 |
+
# This is equivalent to EAGAIN or EWOULDBLOCK under read(2).
|
| 789 |
+
return True
|
| 790 |
+
|
| 791 |
+
if nread < 0:
|
| 792 |
+
# From libuv docs:
|
| 793 |
+
# The callee is responsible for stopping closing the stream
|
| 794 |
+
# when an error happens by calling uv_read_stop() or uv_close().
|
| 795 |
+
# Trying to read from the stream again is undefined.
|
| 796 |
+
#
|
| 797 |
+
# Therefore, we're closing the stream. Since "UVHandle._close()"
|
| 798 |
+
# doesn't raise exceptions unless uvloop is built with DEBUG=1,
|
| 799 |
+
# we don't need try...finally here.
|
| 800 |
+
|
| 801 |
+
if UVLOOP_DEBUG:
|
| 802 |
+
loop._debug_stream_read_errors_total += 1
|
| 803 |
+
|
| 804 |
+
if sc.__read_error_close:
|
| 805 |
+
# Used for getting notified when a pipe is closed.
|
| 806 |
+
# See WriteUnixTransport for the explanation.
|
| 807 |
+
sc._on_eof()
|
| 808 |
+
return True
|
| 809 |
+
|
| 810 |
+
exc = convert_error(nread)
|
| 811 |
+
sc._fatal_error(
|
| 812 |
+
exc, False, "error status in uv_stream_t.read callback")
|
| 813 |
+
return True
|
| 814 |
+
|
| 815 |
+
return False
|
| 816 |
+
|
| 817 |
+
|
| 818 |
+
cdef inline void __uv_stream_on_read_impl(
|
| 819 |
+
uv.uv_stream_t* stream,
|
| 820 |
+
ssize_t nread,
|
| 821 |
+
const uv.uv_buf_t* buf,
|
| 822 |
+
):
|
| 823 |
+
cdef:
|
| 824 |
+
UVStream sc = <UVStream>stream.data
|
| 825 |
+
Loop loop = sc._loop
|
| 826 |
+
|
| 827 |
+
# It's OK to free the buffer early, since nothing will
|
| 828 |
+
# be able to touch it until this method is done.
|
| 829 |
+
__loop_free_buffer(loop)
|
| 830 |
+
|
| 831 |
+
if __uv_stream_on_read_common(sc, loop, nread):
|
| 832 |
+
return
|
| 833 |
+
|
| 834 |
+
try:
|
| 835 |
+
if UVLOOP_DEBUG:
|
| 836 |
+
loop._debug_stream_read_cb_total += 1
|
| 837 |
+
|
| 838 |
+
run_in_context1(
|
| 839 |
+
sc.context,
|
| 840 |
+
sc._protocol_data_received,
|
| 841 |
+
loop._recv_buffer[:nread],
|
| 842 |
+
)
|
| 843 |
+
except BaseException as exc:
|
| 844 |
+
if UVLOOP_DEBUG:
|
| 845 |
+
loop._debug_stream_read_cb_errors_total += 1
|
| 846 |
+
|
| 847 |
+
sc._fatal_error(exc, False)
|
| 848 |
+
|
| 849 |
+
|
| 850 |
+
cdef inline void __uv_stream_on_write_impl(
|
| 851 |
+
uv.uv_write_t* req,
|
| 852 |
+
int status,
|
| 853 |
+
):
|
| 854 |
+
cdef:
|
| 855 |
+
_StreamWriteContext ctx = <_StreamWriteContext> req.data
|
| 856 |
+
UVStream stream = <UVStream>ctx.stream
|
| 857 |
+
|
| 858 |
+
ctx.close()
|
| 859 |
+
|
| 860 |
+
if stream._closed:
|
| 861 |
+
# The stream was closed, there is nothing to do.
|
| 862 |
+
# Even if there is an error, like EPIPE, there
|
| 863 |
+
# is no reason to report it.
|
| 864 |
+
return
|
| 865 |
+
|
| 866 |
+
if status < 0:
|
| 867 |
+
if UVLOOP_DEBUG:
|
| 868 |
+
stream._loop._debug_stream_write_errors_total += 1
|
| 869 |
+
|
| 870 |
+
exc = convert_error(status)
|
| 871 |
+
stream._fatal_error(
|
| 872 |
+
exc, False, "error status in uv_stream_t.write callback")
|
| 873 |
+
return
|
| 874 |
+
|
| 875 |
+
try:
|
| 876 |
+
stream._on_write()
|
| 877 |
+
except BaseException as exc:
|
| 878 |
+
if UVLOOP_DEBUG:
|
| 879 |
+
stream._loop._debug_stream_write_cb_errors_total += 1
|
| 880 |
+
|
| 881 |
+
stream._fatal_error(exc, False)
|
| 882 |
+
|
| 883 |
+
|
| 884 |
+
cdef void __uv_stream_on_read(
|
| 885 |
+
uv.uv_stream_t* stream,
|
| 886 |
+
ssize_t nread,
|
| 887 |
+
const uv.uv_buf_t* buf,
|
| 888 |
+
) noexcept with gil:
|
| 889 |
+
|
| 890 |
+
if __ensure_handle_data(<uv.uv_handle_t*>stream,
|
| 891 |
+
"UVStream read callback") == 0:
|
| 892 |
+
return
|
| 893 |
+
|
| 894 |
+
# Don't need try-finally, __uv_stream_on_read_impl is void
|
| 895 |
+
__uv_stream_on_read_impl(stream, nread, buf)
|
| 896 |
+
|
| 897 |
+
|
| 898 |
+
cdef void __uv_stream_on_write(
|
| 899 |
+
uv.uv_write_t* req,
|
| 900 |
+
int status,
|
| 901 |
+
) noexcept with gil:
|
| 902 |
+
|
| 903 |
+
if UVLOOP_DEBUG:
|
| 904 |
+
if req.data is NULL:
|
| 905 |
+
aio_logger.error(
|
| 906 |
+
'UVStream.write callback called with NULL req.data, status=%r',
|
| 907 |
+
status)
|
| 908 |
+
return
|
| 909 |
+
|
| 910 |
+
# Don't need try-finally, __uv_stream_on_write_impl is void
|
| 911 |
+
__uv_stream_on_write_impl(req, status)
|
| 912 |
+
|
| 913 |
+
|
| 914 |
+
cdef void __uv_stream_buffered_alloc(
|
| 915 |
+
uv.uv_handle_t* stream,
|
| 916 |
+
size_t suggested_size,
|
| 917 |
+
uv.uv_buf_t* uvbuf,
|
| 918 |
+
) noexcept with gil:
|
| 919 |
+
|
| 920 |
+
if __ensure_handle_data(<uv.uv_handle_t*>stream,
|
| 921 |
+
"UVStream alloc buffer callback") == 0:
|
| 922 |
+
return
|
| 923 |
+
|
| 924 |
+
cdef:
|
| 925 |
+
UVStream sc = <UVStream>stream.data
|
| 926 |
+
Loop loop = sc._loop
|
| 927 |
+
Py_buffer* pybuf = &sc._read_pybuf
|
| 928 |
+
int got_buf = 0
|
| 929 |
+
|
| 930 |
+
if sc._read_pybuf_acquired:
|
| 931 |
+
uvbuf.len = 0
|
| 932 |
+
uvbuf.base = NULL
|
| 933 |
+
return
|
| 934 |
+
|
| 935 |
+
sc._read_pybuf_acquired = 0
|
| 936 |
+
try:
|
| 937 |
+
buf = run_in_context1(
|
| 938 |
+
sc.context,
|
| 939 |
+
sc._protocol_get_buffer,
|
| 940 |
+
suggested_size,
|
| 941 |
+
)
|
| 942 |
+
PyObject_GetBuffer(buf, pybuf, PyBUF_WRITABLE)
|
| 943 |
+
got_buf = 1
|
| 944 |
+
except BaseException as exc:
|
| 945 |
+
# Can't call 'sc._fatal_error' or 'sc._close', libuv will SF.
|
| 946 |
+
# We'll do it later in __uv_stream_buffered_on_read when we
|
| 947 |
+
# receive UV_ENOBUFS.
|
| 948 |
+
uvbuf.len = 0
|
| 949 |
+
uvbuf.base = NULL
|
| 950 |
+
return
|
| 951 |
+
|
| 952 |
+
if not pybuf.len:
|
| 953 |
+
uvbuf.len = 0
|
| 954 |
+
uvbuf.base = NULL
|
| 955 |
+
if got_buf:
|
| 956 |
+
PyBuffer_Release(pybuf)
|
| 957 |
+
return
|
| 958 |
+
|
| 959 |
+
sc._read_pybuf_acquired = 1
|
| 960 |
+
uvbuf.base = <char*>pybuf.buf
|
| 961 |
+
uvbuf.len = pybuf.len
|
| 962 |
+
|
| 963 |
+
|
| 964 |
+
cdef void __uv_stream_buffered_on_read(
|
| 965 |
+
uv.uv_stream_t* stream,
|
| 966 |
+
ssize_t nread,
|
| 967 |
+
const uv.uv_buf_t* buf,
|
| 968 |
+
) noexcept with gil:
|
| 969 |
+
|
| 970 |
+
if __ensure_handle_data(<uv.uv_handle_t*>stream,
|
| 971 |
+
"UVStream buffered read callback") == 0:
|
| 972 |
+
return
|
| 973 |
+
|
| 974 |
+
cdef:
|
| 975 |
+
UVStream sc = <UVStream>stream.data
|
| 976 |
+
Loop loop = sc._loop
|
| 977 |
+
Py_buffer* pybuf = &sc._read_pybuf
|
| 978 |
+
|
| 979 |
+
if nread == uv.UV_ENOBUFS:
|
| 980 |
+
sc._fatal_error(
|
| 981 |
+
RuntimeError(
|
| 982 |
+
'unhandled error (or an empty buffer) in get_buffer()'),
|
| 983 |
+
False)
|
| 984 |
+
return
|
| 985 |
+
|
| 986 |
+
try:
|
| 987 |
+
if nread > 0 and not sc._read_pybuf_acquired:
|
| 988 |
+
# From libuv docs:
|
| 989 |
+
# nread is > 0 if there is data available or < 0 on error. When
|
| 990 |
+
# we’ve reached EOF, nread will be set to UV_EOF. When
|
| 991 |
+
# nread < 0, the buf parameter might not point to a valid
|
| 992 |
+
# buffer; in that case buf.len and buf.base are both set to 0.
|
| 993 |
+
raise RuntimeError(
|
| 994 |
+
f'no python buffer is allocated in on_read; nread={nread}')
|
| 995 |
+
|
| 996 |
+
if nread == 0:
|
| 997 |
+
# From libuv docs:
|
| 998 |
+
# nread might be 0, which does not indicate an error or EOF.
|
| 999 |
+
# This is equivalent to EAGAIN or EWOULDBLOCK under read(2).
|
| 1000 |
+
return
|
| 1001 |
+
|
| 1002 |
+
if __uv_stream_on_read_common(sc, loop, nread):
|
| 1003 |
+
return
|
| 1004 |
+
|
| 1005 |
+
if UVLOOP_DEBUG:
|
| 1006 |
+
loop._debug_stream_read_cb_total += 1
|
| 1007 |
+
|
| 1008 |
+
run_in_context1(sc.context, sc._protocol_buffer_updated, nread)
|
| 1009 |
+
except BaseException as exc:
|
| 1010 |
+
if UVLOOP_DEBUG:
|
| 1011 |
+
loop._debug_stream_read_cb_errors_total += 1
|
| 1012 |
+
|
| 1013 |
+
sc._fatal_error(exc, False)
|
| 1014 |
+
finally:
|
| 1015 |
+
sc._read_pybuf_acquired = 0
|
| 1016 |
+
PyBuffer_Release(pybuf)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/streamserver.pxd
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVStreamServer(UVSocketHandle):
|
| 2 |
+
cdef:
|
| 3 |
+
int backlog
|
| 4 |
+
object ssl
|
| 5 |
+
object ssl_handshake_timeout
|
| 6 |
+
object ssl_shutdown_timeout
|
| 7 |
+
object protocol_factory
|
| 8 |
+
bint opened
|
| 9 |
+
Server _server
|
| 10 |
+
|
| 11 |
+
# All "inline" methods are final
|
| 12 |
+
|
| 13 |
+
cdef inline _init(self, Loop loop, object protocol_factory,
|
| 14 |
+
Server server,
|
| 15 |
+
object backlog,
|
| 16 |
+
object ssl,
|
| 17 |
+
object ssl_handshake_timeout,
|
| 18 |
+
object ssl_shutdown_timeout)
|
| 19 |
+
|
| 20 |
+
cdef inline _mark_as_open(self)
|
| 21 |
+
|
| 22 |
+
cdef inline listen(self)
|
| 23 |
+
cdef inline _on_listen(self)
|
| 24 |
+
|
| 25 |
+
cdef UVStream _make_new_transport(self, object protocol, object waiter,
|
| 26 |
+
object context)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/streamserver.pyx
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.no_gc_clear
|
| 2 |
+
cdef class UVStreamServer(UVSocketHandle):
|
| 3 |
+
|
| 4 |
+
def __cinit__(self):
|
| 5 |
+
self.opened = 0
|
| 6 |
+
self._server = None
|
| 7 |
+
self.ssl = None
|
| 8 |
+
self.ssl_handshake_timeout = None
|
| 9 |
+
self.ssl_shutdown_timeout = None
|
| 10 |
+
self.protocol_factory = None
|
| 11 |
+
|
| 12 |
+
cdef inline _init(self, Loop loop, object protocol_factory,
|
| 13 |
+
Server server,
|
| 14 |
+
object backlog,
|
| 15 |
+
object ssl,
|
| 16 |
+
object ssl_handshake_timeout,
|
| 17 |
+
object ssl_shutdown_timeout):
|
| 18 |
+
|
| 19 |
+
if not isinstance(backlog, int):
|
| 20 |
+
# Don't allow floats
|
| 21 |
+
raise TypeError('integer argument expected, got {}'.format(
|
| 22 |
+
type(backlog).__name__))
|
| 23 |
+
|
| 24 |
+
if ssl is not None:
|
| 25 |
+
if not isinstance(ssl, ssl_SSLContext):
|
| 26 |
+
raise TypeError(
|
| 27 |
+
'ssl is expected to be None or an instance of '
|
| 28 |
+
'ssl.SSLContext, got {!r}'.format(ssl))
|
| 29 |
+
else:
|
| 30 |
+
if ssl_handshake_timeout is not None:
|
| 31 |
+
raise ValueError(
|
| 32 |
+
'ssl_handshake_timeout is only meaningful with ssl')
|
| 33 |
+
if ssl_shutdown_timeout is not None:
|
| 34 |
+
raise ValueError(
|
| 35 |
+
'ssl_shutdown_timeout is only meaningful with ssl')
|
| 36 |
+
|
| 37 |
+
self.backlog = backlog
|
| 38 |
+
self.ssl = ssl
|
| 39 |
+
self.ssl_handshake_timeout = ssl_handshake_timeout
|
| 40 |
+
self.ssl_shutdown_timeout = ssl_shutdown_timeout
|
| 41 |
+
|
| 42 |
+
self._start_init(loop)
|
| 43 |
+
self.protocol_factory = protocol_factory
|
| 44 |
+
self._server = server
|
| 45 |
+
|
| 46 |
+
cdef inline listen(self):
|
| 47 |
+
cdef int err
|
| 48 |
+
self._ensure_alive()
|
| 49 |
+
|
| 50 |
+
if self.protocol_factory is None:
|
| 51 |
+
raise RuntimeError('unable to listen(); no protocol_factory')
|
| 52 |
+
|
| 53 |
+
if self.opened != 1:
|
| 54 |
+
raise RuntimeError('unopened TCPServer')
|
| 55 |
+
|
| 56 |
+
self.context = Context_CopyCurrent()
|
| 57 |
+
|
| 58 |
+
err = uv.uv_listen(<uv.uv_stream_t*> self._handle,
|
| 59 |
+
self.backlog,
|
| 60 |
+
__uv_streamserver_on_listen)
|
| 61 |
+
if err < 0:
|
| 62 |
+
exc = convert_error(err)
|
| 63 |
+
self._fatal_error(exc, True)
|
| 64 |
+
return
|
| 65 |
+
|
| 66 |
+
cdef inline _on_listen(self):
|
| 67 |
+
cdef UVStream client
|
| 68 |
+
|
| 69 |
+
protocol = run_in_context(self.context, self.protocol_factory)
|
| 70 |
+
|
| 71 |
+
if self.ssl is None:
|
| 72 |
+
client = self._make_new_transport(protocol, None, self.context)
|
| 73 |
+
|
| 74 |
+
else:
|
| 75 |
+
waiter = self._loop._new_future()
|
| 76 |
+
|
| 77 |
+
ssl_protocol = SSLProtocol(
|
| 78 |
+
self._loop, protocol, self.ssl,
|
| 79 |
+
waiter,
|
| 80 |
+
server_side=True,
|
| 81 |
+
server_hostname=None,
|
| 82 |
+
ssl_handshake_timeout=self.ssl_handshake_timeout,
|
| 83 |
+
ssl_shutdown_timeout=self.ssl_shutdown_timeout)
|
| 84 |
+
|
| 85 |
+
client = self._make_new_transport(ssl_protocol, None, self.context)
|
| 86 |
+
|
| 87 |
+
waiter.add_done_callback(
|
| 88 |
+
ft_partial(self.__on_ssl_connected, client))
|
| 89 |
+
|
| 90 |
+
client._accept(<UVStream>self)
|
| 91 |
+
|
| 92 |
+
cdef _fatal_error(self, exc, throw, reason=None):
|
| 93 |
+
# Overload UVHandle._fatal_error
|
| 94 |
+
|
| 95 |
+
self._close()
|
| 96 |
+
|
| 97 |
+
if not isinstance(exc, OSError):
|
| 98 |
+
|
| 99 |
+
if throw or self._loop is None:
|
| 100 |
+
raise exc
|
| 101 |
+
|
| 102 |
+
msg = f'Fatal error on server {self.__class__.__name__}'
|
| 103 |
+
if reason is not None:
|
| 104 |
+
msg = f'{msg} ({reason})'
|
| 105 |
+
|
| 106 |
+
self._loop.call_exception_handler({
|
| 107 |
+
'message': msg,
|
| 108 |
+
'exception': exc,
|
| 109 |
+
})
|
| 110 |
+
|
| 111 |
+
cdef inline _mark_as_open(self):
|
| 112 |
+
self.opened = 1
|
| 113 |
+
|
| 114 |
+
cdef UVStream _make_new_transport(self, object protocol, object waiter,
|
| 115 |
+
object context):
|
| 116 |
+
raise NotImplementedError
|
| 117 |
+
|
| 118 |
+
def __on_ssl_connected(self, transport, fut):
|
| 119 |
+
exc = fut.exception()
|
| 120 |
+
if exc is not None:
|
| 121 |
+
transport._force_close(exc)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
cdef void __uv_streamserver_on_listen(
|
| 125 |
+
uv.uv_stream_t* handle,
|
| 126 |
+
int status,
|
| 127 |
+
) noexcept with gil:
|
| 128 |
+
|
| 129 |
+
# callback for uv_listen
|
| 130 |
+
|
| 131 |
+
if __ensure_handle_data(<uv.uv_handle_t*>handle,
|
| 132 |
+
"UVStream listen callback") == 0:
|
| 133 |
+
return
|
| 134 |
+
|
| 135 |
+
cdef:
|
| 136 |
+
UVStreamServer stream = <UVStreamServer> handle.data
|
| 137 |
+
|
| 138 |
+
if status < 0:
|
| 139 |
+
if UVLOOP_DEBUG:
|
| 140 |
+
stream._loop._debug_stream_listen_errors_total += 1
|
| 141 |
+
|
| 142 |
+
exc = convert_error(status)
|
| 143 |
+
stream._fatal_error(
|
| 144 |
+
exc, False, "error status in uv_stream_t.listen callback")
|
| 145 |
+
return
|
| 146 |
+
|
| 147 |
+
try:
|
| 148 |
+
stream._on_listen()
|
| 149 |
+
except BaseException as exc:
|
| 150 |
+
stream._error(exc, False)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/tcp.pxd
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class TCPServer(UVStreamServer):
|
| 2 |
+
cdef bind(self, system.sockaddr* addr, unsigned int flags=*)
|
| 3 |
+
|
| 4 |
+
@staticmethod
|
| 5 |
+
cdef TCPServer new(Loop loop, object protocol_factory, Server server,
|
| 6 |
+
unsigned int flags,
|
| 7 |
+
object backlog,
|
| 8 |
+
object ssl,
|
| 9 |
+
object ssl_handshake_timeout,
|
| 10 |
+
object ssl_shutdown_timeout)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
cdef class TCPTransport(UVStream):
|
| 14 |
+
cdef:
|
| 15 |
+
bint __peername_set
|
| 16 |
+
bint __sockname_set
|
| 17 |
+
system.sockaddr_storage __peername
|
| 18 |
+
system.sockaddr_storage __sockname
|
| 19 |
+
|
| 20 |
+
cdef bind(self, system.sockaddr* addr, unsigned int flags=*)
|
| 21 |
+
cdef connect(self, system.sockaddr* addr)
|
| 22 |
+
cdef _set_nodelay(self)
|
| 23 |
+
|
| 24 |
+
@staticmethod
|
| 25 |
+
cdef TCPTransport new(Loop loop, object protocol, Server server,
|
| 26 |
+
object waiter, object context)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/tcp.pyx
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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PyMem_RawMalloc(sizeof(uv.uv_tcp_t))
|
| 5 |
+
if handle._handle is NULL:
|
| 6 |
+
handle._abort_init()
|
| 7 |
+
raise MemoryError()
|
| 8 |
+
|
| 9 |
+
err = uv.uv_tcp_init_ex(handle._loop.uvloop,
|
| 10 |
+
<uv.uv_tcp_t*>handle._handle,
|
| 11 |
+
flags)
|
| 12 |
+
if err < 0:
|
| 13 |
+
handle._abort_init()
|
| 14 |
+
raise convert_error(err)
|
| 15 |
+
|
| 16 |
+
handle._finish_init()
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
cdef __tcp_bind(UVStream handle, system.sockaddr* addr, unsigned int flags):
|
| 20 |
+
cdef int err
|
| 21 |
+
err = uv.uv_tcp_bind(<uv.uv_tcp_t *>handle._handle,
|
| 22 |
+
addr, flags)
|
| 23 |
+
if err < 0:
|
| 24 |
+
exc = convert_error(err)
|
| 25 |
+
raise exc
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
cdef __tcp_open(UVStream handle, int sockfd):
|
| 29 |
+
cdef int err
|
| 30 |
+
err = uv.uv_tcp_open(<uv.uv_tcp_t *>handle._handle,
|
| 31 |
+
<uv.uv_os_sock_t>sockfd)
|
| 32 |
+
if err < 0:
|
| 33 |
+
exc = convert_error(err)
|
| 34 |
+
raise exc
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
cdef __tcp_get_socket(UVSocketHandle handle):
|
| 38 |
+
cdef:
|
| 39 |
+
int buf_len = sizeof(system.sockaddr_storage)
|
| 40 |
+
int fileno
|
| 41 |
+
int err
|
| 42 |
+
system.sockaddr_storage buf
|
| 43 |
+
|
| 44 |
+
fileno = handle._fileno()
|
| 45 |
+
|
| 46 |
+
err = uv.uv_tcp_getsockname(<uv.uv_tcp_t*>handle._handle,
|
| 47 |
+
<system.sockaddr*>&buf,
|
| 48 |
+
&buf_len)
|
| 49 |
+
if err < 0:
|
| 50 |
+
raise convert_error(err)
|
| 51 |
+
|
| 52 |
+
return PseudoSocket(buf.ss_family, uv.SOCK_STREAM, 0, fileno)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
@cython.no_gc_clear
|
| 56 |
+
cdef class TCPServer(UVStreamServer):
|
| 57 |
+
|
| 58 |
+
@staticmethod
|
| 59 |
+
cdef TCPServer new(Loop loop, object protocol_factory, Server server,
|
| 60 |
+
unsigned int flags,
|
| 61 |
+
object backlog,
|
| 62 |
+
object ssl,
|
| 63 |
+
object ssl_handshake_timeout,
|
| 64 |
+
object ssl_shutdown_timeout):
|
| 65 |
+
|
| 66 |
+
cdef TCPServer handle
|
| 67 |
+
handle = TCPServer.__new__(TCPServer)
|
| 68 |
+
handle._init(loop, protocol_factory, server, backlog,
|
| 69 |
+
ssl, ssl_handshake_timeout, ssl_shutdown_timeout)
|
| 70 |
+
__tcp_init_uv_handle(<UVStream>handle, loop, flags)
|
| 71 |
+
return handle
|
| 72 |
+
|
| 73 |
+
cdef _new_socket(self):
|
| 74 |
+
return __tcp_get_socket(<UVSocketHandle>self)
|
| 75 |
+
|
| 76 |
+
cdef _open(self, int sockfd):
|
| 77 |
+
self._ensure_alive()
|
| 78 |
+
try:
|
| 79 |
+
__tcp_open(<UVStream>self, sockfd)
|
| 80 |
+
except Exception as exc:
|
| 81 |
+
self._fatal_error(exc, True)
|
| 82 |
+
else:
|
| 83 |
+
self._mark_as_open()
|
| 84 |
+
|
| 85 |
+
cdef bind(self, system.sockaddr* addr, unsigned int flags=0):
|
| 86 |
+
self._ensure_alive()
|
| 87 |
+
try:
|
| 88 |
+
__tcp_bind(<UVStream>self, addr, flags)
|
| 89 |
+
except Exception as exc:
|
| 90 |
+
self._fatal_error(exc, True)
|
| 91 |
+
else:
|
| 92 |
+
self._mark_as_open()
|
| 93 |
+
|
| 94 |
+
cdef UVStream _make_new_transport(self, object protocol, object waiter,
|
| 95 |
+
object context):
|
| 96 |
+
cdef TCPTransport tr
|
| 97 |
+
tr = TCPTransport.new(self._loop, protocol, self._server, waiter,
|
| 98 |
+
context)
|
| 99 |
+
return <UVStream>tr
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
@cython.no_gc_clear
|
| 103 |
+
cdef class TCPTransport(UVStream):
|
| 104 |
+
|
| 105 |
+
@staticmethod
|
| 106 |
+
cdef TCPTransport new(Loop loop, object protocol, Server server,
|
| 107 |
+
object waiter, object context):
|
| 108 |
+
|
| 109 |
+
cdef TCPTransport handle
|
| 110 |
+
handle = TCPTransport.__new__(TCPTransport)
|
| 111 |
+
handle._init(loop, protocol, server, waiter, context)
|
| 112 |
+
__tcp_init_uv_handle(<UVStream>handle, loop, uv.AF_UNSPEC)
|
| 113 |
+
handle.__peername_set = 0
|
| 114 |
+
handle.__sockname_set = 0
|
| 115 |
+
handle._set_nodelay()
|
| 116 |
+
return handle
|
| 117 |
+
|
| 118 |
+
cdef _set_nodelay(self):
|
| 119 |
+
cdef int err
|
| 120 |
+
self._ensure_alive()
|
| 121 |
+
err = uv.uv_tcp_nodelay(<uv.uv_tcp_t*>self._handle, 1)
|
| 122 |
+
if err < 0:
|
| 123 |
+
raise convert_error(err)
|
| 124 |
+
|
| 125 |
+
cdef _call_connection_made(self):
|
| 126 |
+
# asyncio saves peername & sockname when transports are instantiated,
|
| 127 |
+
# so that they're accessible even after the transport is closed.
|
| 128 |
+
# We are doing the same thing here, except that we create Python
|
| 129 |
+
# objects lazily, on request in get_extra_info()
|
| 130 |
+
|
| 131 |
+
cdef:
|
| 132 |
+
int err
|
| 133 |
+
int buf_len
|
| 134 |
+
|
| 135 |
+
buf_len = sizeof(system.sockaddr_storage)
|
| 136 |
+
err = uv.uv_tcp_getsockname(<uv.uv_tcp_t*>self._handle,
|
| 137 |
+
<system.sockaddr*>&self.__sockname,
|
| 138 |
+
&buf_len)
|
| 139 |
+
if err >= 0:
|
| 140 |
+
# Ignore errors, this is an optional thing.
|
| 141 |
+
# If something serious is going on, the transport
|
| 142 |
+
# will crash later (in roughly the same way how
|
| 143 |
+
# an asyncio transport would.)
|
| 144 |
+
self.__sockname_set = 1
|
| 145 |
+
|
| 146 |
+
buf_len = sizeof(system.sockaddr_storage)
|
| 147 |
+
err = uv.uv_tcp_getpeername(<uv.uv_tcp_t*>self._handle,
|
| 148 |
+
<system.sockaddr*>&self.__peername,
|
| 149 |
+
&buf_len)
|
| 150 |
+
if err >= 0:
|
| 151 |
+
# Same as few lines above -- we don't really care
|
| 152 |
+
# about error case here.
|
| 153 |
+
self.__peername_set = 1
|
| 154 |
+
|
| 155 |
+
UVBaseTransport._call_connection_made(self)
|
| 156 |
+
|
| 157 |
+
def get_extra_info(self, name, default=None):
|
| 158 |
+
if name == 'sockname':
|
| 159 |
+
if self.__sockname_set:
|
| 160 |
+
return __convert_sockaddr_to_pyaddr(
|
| 161 |
+
<system.sockaddr*>&self.__sockname)
|
| 162 |
+
elif name == 'peername':
|
| 163 |
+
if self.__peername_set:
|
| 164 |
+
return __convert_sockaddr_to_pyaddr(
|
| 165 |
+
<system.sockaddr*>&self.__peername)
|
| 166 |
+
return super().get_extra_info(name, default)
|
| 167 |
+
|
| 168 |
+
cdef _new_socket(self):
|
| 169 |
+
return __tcp_get_socket(<UVSocketHandle>self)
|
| 170 |
+
|
| 171 |
+
cdef bind(self, system.sockaddr* addr, unsigned int flags=0):
|
| 172 |
+
self._ensure_alive()
|
| 173 |
+
__tcp_bind(<UVStream>self, addr, flags)
|
| 174 |
+
|
| 175 |
+
cdef _open(self, int sockfd):
|
| 176 |
+
self._ensure_alive()
|
| 177 |
+
__tcp_open(<UVStream>self, sockfd)
|
| 178 |
+
|
| 179 |
+
cdef connect(self, system.sockaddr* addr):
|
| 180 |
+
cdef _TCPConnectRequest req
|
| 181 |
+
req = _TCPConnectRequest(self._loop, self)
|
| 182 |
+
req.connect(addr)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
cdef class _TCPConnectRequest(UVRequest):
|
| 186 |
+
cdef:
|
| 187 |
+
TCPTransport transport
|
| 188 |
+
uv.uv_connect_t _req_data
|
| 189 |
+
|
| 190 |
+
def __cinit__(self, loop, transport):
|
| 191 |
+
self.request = <uv.uv_req_t*>&self._req_data
|
| 192 |
+
self.request.data = <void*>self
|
| 193 |
+
self.transport = transport
|
| 194 |
+
|
| 195 |
+
cdef connect(self, system.sockaddr* addr):
|
| 196 |
+
cdef int err
|
| 197 |
+
err = uv.uv_tcp_connect(<uv.uv_connect_t*>self.request,
|
| 198 |
+
<uv.uv_tcp_t*>self.transport._handle,
|
| 199 |
+
addr,
|
| 200 |
+
__tcp_connect_callback)
|
| 201 |
+
if err < 0:
|
| 202 |
+
exc = convert_error(err)
|
| 203 |
+
self.on_done()
|
| 204 |
+
raise exc
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
cdef void __tcp_connect_callback(
|
| 208 |
+
uv.uv_connect_t* req,
|
| 209 |
+
int status,
|
| 210 |
+
) noexcept with gil:
|
| 211 |
+
cdef:
|
| 212 |
+
_TCPConnectRequest wrapper
|
| 213 |
+
TCPTransport transport
|
| 214 |
+
|
| 215 |
+
wrapper = <_TCPConnectRequest> req.data
|
| 216 |
+
transport = wrapper.transport
|
| 217 |
+
|
| 218 |
+
if status < 0:
|
| 219 |
+
exc = convert_error(status)
|
| 220 |
+
else:
|
| 221 |
+
exc = None
|
| 222 |
+
|
| 223 |
+
try:
|
| 224 |
+
transport._on_connect(exc)
|
| 225 |
+
except BaseException as ex:
|
| 226 |
+
wrapper.transport._fatal_error(ex, False)
|
| 227 |
+
finally:
|
| 228 |
+
wrapper.on_done()
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/timer.pxd
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVTimer(UVHandle):
|
| 2 |
+
cdef:
|
| 3 |
+
method_t callback
|
| 4 |
+
object ctx
|
| 5 |
+
bint running
|
| 6 |
+
uint64_t timeout
|
| 7 |
+
uint64_t start_t
|
| 8 |
+
|
| 9 |
+
cdef _init(self, Loop loop, method_t callback, object ctx,
|
| 10 |
+
uint64_t timeout)
|
| 11 |
+
|
| 12 |
+
cdef stop(self)
|
| 13 |
+
cdef start(self)
|
| 14 |
+
cdef get_when(self)
|
| 15 |
+
|
| 16 |
+
@staticmethod
|
| 17 |
+
cdef UVTimer new(Loop loop, method_t callback, object ctx,
|
| 18 |
+
uint64_t timeout)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/timer.pyx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.no_gc_clear
|
| 2 |
+
cdef class UVTimer(UVHandle):
|
| 3 |
+
cdef _init(self, Loop loop, method_t callback, object ctx,
|
| 4 |
+
uint64_t timeout):
|
| 5 |
+
|
| 6 |
+
cdef int err
|
| 7 |
+
|
| 8 |
+
self._start_init(loop)
|
| 9 |
+
|
| 10 |
+
self._handle = <uv.uv_handle_t*> PyMem_RawMalloc(sizeof(uv.uv_timer_t))
|
| 11 |
+
if self._handle is NULL:
|
| 12 |
+
self._abort_init()
|
| 13 |
+
raise MemoryError()
|
| 14 |
+
|
| 15 |
+
err = uv.uv_timer_init(self._loop.uvloop, <uv.uv_timer_t*>self._handle)
|
| 16 |
+
if err < 0:
|
| 17 |
+
self._abort_init()
|
| 18 |
+
raise convert_error(err)
|
| 19 |
+
|
| 20 |
+
self._finish_init()
|
| 21 |
+
|
| 22 |
+
self.callback = callback
|
| 23 |
+
self.ctx = ctx
|
| 24 |
+
self.running = 0
|
| 25 |
+
self.timeout = timeout
|
| 26 |
+
self.start_t = 0
|
| 27 |
+
|
| 28 |
+
cdef stop(self):
|
| 29 |
+
cdef int err
|
| 30 |
+
|
| 31 |
+
if not self._is_alive():
|
| 32 |
+
self.running = 0
|
| 33 |
+
return
|
| 34 |
+
|
| 35 |
+
if self.running == 1:
|
| 36 |
+
err = uv.uv_timer_stop(<uv.uv_timer_t*>self._handle)
|
| 37 |
+
self.running = 0
|
| 38 |
+
if err < 0:
|
| 39 |
+
exc = convert_error(err)
|
| 40 |
+
self._fatal_error(exc, True)
|
| 41 |
+
return
|
| 42 |
+
|
| 43 |
+
cdef start(self):
|
| 44 |
+
cdef int err
|
| 45 |
+
|
| 46 |
+
self._ensure_alive()
|
| 47 |
+
|
| 48 |
+
if self.running == 0:
|
| 49 |
+
# Update libuv internal time.
|
| 50 |
+
uv.uv_update_time(self._loop.uvloop) # void
|
| 51 |
+
self.start_t = uv.uv_now(self._loop.uvloop)
|
| 52 |
+
|
| 53 |
+
err = uv.uv_timer_start(<uv.uv_timer_t*>self._handle,
|
| 54 |
+
__uvtimer_callback,
|
| 55 |
+
self.timeout, 0)
|
| 56 |
+
if err < 0:
|
| 57 |
+
exc = convert_error(err)
|
| 58 |
+
self._fatal_error(exc, True)
|
| 59 |
+
return
|
| 60 |
+
self.running = 1
|
| 61 |
+
|
| 62 |
+
cdef get_when(self):
|
| 63 |
+
return self.start_t + self.timeout
|
| 64 |
+
|
| 65 |
+
@staticmethod
|
| 66 |
+
cdef UVTimer new(Loop loop, method_t callback, object ctx,
|
| 67 |
+
uint64_t timeout):
|
| 68 |
+
|
| 69 |
+
cdef UVTimer handle
|
| 70 |
+
handle = UVTimer.__new__(UVTimer)
|
| 71 |
+
handle._init(loop, callback, ctx, timeout)
|
| 72 |
+
return handle
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
cdef void __uvtimer_callback(
|
| 76 |
+
uv.uv_timer_t* handle,
|
| 77 |
+
) noexcept with gil:
|
| 78 |
+
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVTimer callback") == 0:
|
| 79 |
+
return
|
| 80 |
+
|
| 81 |
+
cdef:
|
| 82 |
+
UVTimer timer = <UVTimer> handle.data
|
| 83 |
+
method_t cb = timer.callback
|
| 84 |
+
|
| 85 |
+
timer.running = 0
|
| 86 |
+
try:
|
| 87 |
+
cb(timer.ctx)
|
| 88 |
+
except BaseException as ex:
|
| 89 |
+
timer._error(ex, False)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/udp.pxd
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UDPTransport(UVBaseTransport):
|
| 2 |
+
cdef:
|
| 3 |
+
bint __receiving
|
| 4 |
+
int _family
|
| 5 |
+
object _address
|
| 6 |
+
|
| 7 |
+
cdef _init(self, Loop loop, unsigned int family)
|
| 8 |
+
cdef _set_address(self, system.addrinfo *addr)
|
| 9 |
+
|
| 10 |
+
cdef _connect(self, system.sockaddr* addr, size_t addr_len)
|
| 11 |
+
|
| 12 |
+
cdef _bind(self, system.sockaddr* addr)
|
| 13 |
+
cdef open(self, int family, int sockfd)
|
| 14 |
+
cdef _set_broadcast(self, bint on)
|
| 15 |
+
|
| 16 |
+
cdef inline __receiving_started(self)
|
| 17 |
+
cdef inline __receiving_stopped(self)
|
| 18 |
+
|
| 19 |
+
cdef _send(self, object data, object addr)
|
| 20 |
+
|
| 21 |
+
cdef _on_receive(self, bytes data, object exc, object addr)
|
| 22 |
+
cdef _on_sent(self, object exc, object context=*)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/handles/udp.pyx
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.no_gc_clear
|
| 2 |
+
@cython.freelist(DEFAULT_FREELIST_SIZE)
|
| 3 |
+
cdef class _UDPSendContext:
|
| 4 |
+
# used to hold additional write request information for uv_write
|
| 5 |
+
|
| 6 |
+
cdef:
|
| 7 |
+
uv.uv_udp_send_t req
|
| 8 |
+
|
| 9 |
+
uv.uv_buf_t uv_buf
|
| 10 |
+
Py_buffer py_buf
|
| 11 |
+
|
| 12 |
+
UDPTransport udp
|
| 13 |
+
|
| 14 |
+
bint closed
|
| 15 |
+
|
| 16 |
+
cdef close(self):
|
| 17 |
+
if self.closed:
|
| 18 |
+
return
|
| 19 |
+
|
| 20 |
+
self.closed = 1
|
| 21 |
+
PyBuffer_Release(&self.py_buf) # void
|
| 22 |
+
self.req.data = NULL
|
| 23 |
+
self.uv_buf.base = NULL
|
| 24 |
+
Py_DECREF(self)
|
| 25 |
+
self.udp = None
|
| 26 |
+
|
| 27 |
+
@staticmethod
|
| 28 |
+
cdef _UDPSendContext new(UDPTransport udp, object data):
|
| 29 |
+
cdef _UDPSendContext ctx
|
| 30 |
+
ctx = _UDPSendContext.__new__(_UDPSendContext)
|
| 31 |
+
ctx.udp = None
|
| 32 |
+
ctx.closed = 1
|
| 33 |
+
|
| 34 |
+
ctx.req.data = <void*> ctx
|
| 35 |
+
Py_INCREF(ctx)
|
| 36 |
+
|
| 37 |
+
PyObject_GetBuffer(data, &ctx.py_buf, PyBUF_SIMPLE)
|
| 38 |
+
ctx.uv_buf.base = <char*>ctx.py_buf.buf
|
| 39 |
+
ctx.uv_buf.len = ctx.py_buf.len
|
| 40 |
+
ctx.udp = udp
|
| 41 |
+
|
| 42 |
+
ctx.closed = 0
|
| 43 |
+
return ctx
|
| 44 |
+
|
| 45 |
+
def __dealloc__(self):
|
| 46 |
+
if UVLOOP_DEBUG:
|
| 47 |
+
if not self.closed:
|
| 48 |
+
raise RuntimeError(
|
| 49 |
+
'open _UDPSendContext is being deallocated')
|
| 50 |
+
self.udp = None
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
@cython.no_gc_clear
|
| 54 |
+
cdef class UDPTransport(UVBaseTransport):
|
| 55 |
+
def __cinit__(self):
|
| 56 |
+
self._family = uv.AF_UNSPEC
|
| 57 |
+
self.__receiving = 0
|
| 58 |
+
self._address = None
|
| 59 |
+
self.context = Context_CopyCurrent()
|
| 60 |
+
|
| 61 |
+
cdef _init(self, Loop loop, unsigned int family):
|
| 62 |
+
cdef int err
|
| 63 |
+
|
| 64 |
+
self._start_init(loop)
|
| 65 |
+
|
| 66 |
+
self._handle = <uv.uv_handle_t*>PyMem_RawMalloc(sizeof(uv.uv_udp_t))
|
| 67 |
+
if self._handle is NULL:
|
| 68 |
+
self._abort_init()
|
| 69 |
+
raise MemoryError()
|
| 70 |
+
|
| 71 |
+
err = uv.uv_udp_init_ex(loop.uvloop,
|
| 72 |
+
<uv.uv_udp_t*>self._handle,
|
| 73 |
+
family)
|
| 74 |
+
if err < 0:
|
| 75 |
+
self._abort_init()
|
| 76 |
+
raise convert_error(err)
|
| 77 |
+
|
| 78 |
+
if family in (uv.AF_INET, uv.AF_INET6):
|
| 79 |
+
self._family = family
|
| 80 |
+
|
| 81 |
+
self._finish_init()
|
| 82 |
+
|
| 83 |
+
cdef _set_address(self, system.addrinfo *addr):
|
| 84 |
+
self._address = __convert_sockaddr_to_pyaddr(addr.ai_addr)
|
| 85 |
+
|
| 86 |
+
cdef _connect(self, system.sockaddr* addr, size_t addr_len):
|
| 87 |
+
cdef int err
|
| 88 |
+
err = uv.uv_udp_connect(<uv.uv_udp_t*>self._handle, addr)
|
| 89 |
+
if err < 0:
|
| 90 |
+
exc = convert_error(err)
|
| 91 |
+
raise exc
|
| 92 |
+
|
| 93 |
+
cdef open(self, int family, int sockfd):
|
| 94 |
+
if family in (uv.AF_INET, uv.AF_INET6, uv.AF_UNIX):
|
| 95 |
+
self._family = family
|
| 96 |
+
else:
|
| 97 |
+
raise ValueError(
|
| 98 |
+
'cannot open a UDP handle, invalid family {}'.format(family))
|
| 99 |
+
|
| 100 |
+
cdef int err
|
| 101 |
+
err = uv.uv_udp_open(<uv.uv_udp_t*>self._handle,
|
| 102 |
+
<uv.uv_os_sock_t>sockfd)
|
| 103 |
+
|
| 104 |
+
if err < 0:
|
| 105 |
+
exc = convert_error(err)
|
| 106 |
+
raise exc
|
| 107 |
+
|
| 108 |
+
cdef _bind(self, system.sockaddr* addr):
|
| 109 |
+
cdef:
|
| 110 |
+
int err
|
| 111 |
+
int flags = 0
|
| 112 |
+
|
| 113 |
+
self._ensure_alive()
|
| 114 |
+
|
| 115 |
+
err = uv.uv_udp_bind(<uv.uv_udp_t*>self._handle, addr, flags)
|
| 116 |
+
if err < 0:
|
| 117 |
+
exc = convert_error(err)
|
| 118 |
+
raise exc
|
| 119 |
+
|
| 120 |
+
cdef _set_broadcast(self, bint on):
|
| 121 |
+
cdef int err
|
| 122 |
+
|
| 123 |
+
self._ensure_alive()
|
| 124 |
+
|
| 125 |
+
err = uv.uv_udp_set_broadcast(<uv.uv_udp_t*>self._handle, on)
|
| 126 |
+
if err < 0:
|
| 127 |
+
exc = convert_error(err)
|
| 128 |
+
raise exc
|
| 129 |
+
|
| 130 |
+
cdef size_t _get_write_buffer_size(self):
|
| 131 |
+
if self._handle is NULL:
|
| 132 |
+
return 0
|
| 133 |
+
return (<uv.uv_udp_t*>self._handle).send_queue_size
|
| 134 |
+
|
| 135 |
+
cdef bint _is_reading(self):
|
| 136 |
+
return self.__receiving
|
| 137 |
+
|
| 138 |
+
cdef _start_reading(self):
|
| 139 |
+
cdef int err
|
| 140 |
+
|
| 141 |
+
if self.__receiving:
|
| 142 |
+
return
|
| 143 |
+
|
| 144 |
+
self._ensure_alive()
|
| 145 |
+
|
| 146 |
+
err = uv.uv_udp_recv_start(<uv.uv_udp_t*>self._handle,
|
| 147 |
+
__loop_alloc_buffer,
|
| 148 |
+
__uv_udp_on_receive)
|
| 149 |
+
|
| 150 |
+
if err < 0:
|
| 151 |
+
exc = convert_error(err)
|
| 152 |
+
self._fatal_error(exc, True)
|
| 153 |
+
return
|
| 154 |
+
else:
|
| 155 |
+
# UDPTransport must live until the read callback is called
|
| 156 |
+
self.__receiving_started()
|
| 157 |
+
|
| 158 |
+
cdef _stop_reading(self):
|
| 159 |
+
cdef int err
|
| 160 |
+
|
| 161 |
+
if not self.__receiving:
|
| 162 |
+
return
|
| 163 |
+
|
| 164 |
+
self._ensure_alive()
|
| 165 |
+
|
| 166 |
+
err = uv.uv_udp_recv_stop(<uv.uv_udp_t*>self._handle)
|
| 167 |
+
if err < 0:
|
| 168 |
+
exc = convert_error(err)
|
| 169 |
+
self._fatal_error(exc, True)
|
| 170 |
+
return
|
| 171 |
+
else:
|
| 172 |
+
self.__receiving_stopped()
|
| 173 |
+
|
| 174 |
+
cdef inline __receiving_started(self):
|
| 175 |
+
if self.__receiving:
|
| 176 |
+
return
|
| 177 |
+
self.__receiving = 1
|
| 178 |
+
Py_INCREF(self)
|
| 179 |
+
|
| 180 |
+
cdef inline __receiving_stopped(self):
|
| 181 |
+
if not self.__receiving:
|
| 182 |
+
return
|
| 183 |
+
self.__receiving = 0
|
| 184 |
+
Py_DECREF(self)
|
| 185 |
+
|
| 186 |
+
cdef _new_socket(self):
|
| 187 |
+
if self._family not in (uv.AF_INET, uv.AF_INET6, uv.AF_UNIX):
|
| 188 |
+
raise RuntimeError(
|
| 189 |
+
'UDPTransport.family is undefined; '
|
| 190 |
+
'cannot create python socket')
|
| 191 |
+
|
| 192 |
+
fileno = self._fileno()
|
| 193 |
+
return PseudoSocket(self._family, uv.SOCK_DGRAM, 0, fileno)
|
| 194 |
+
|
| 195 |
+
cdef _send(self, object data, object addr):
|
| 196 |
+
cdef:
|
| 197 |
+
_UDPSendContext ctx
|
| 198 |
+
system.sockaddr_storage saddr_st
|
| 199 |
+
system.sockaddr *saddr
|
| 200 |
+
Py_buffer try_pybuf
|
| 201 |
+
uv.uv_buf_t try_uvbuf
|
| 202 |
+
|
| 203 |
+
self._ensure_alive()
|
| 204 |
+
|
| 205 |
+
if self._family not in (uv.AF_INET, uv.AF_INET6, uv.AF_UNIX):
|
| 206 |
+
raise RuntimeError('UDPTransport.family is undefined; cannot send')
|
| 207 |
+
|
| 208 |
+
if addr is None:
|
| 209 |
+
saddr = NULL
|
| 210 |
+
else:
|
| 211 |
+
try:
|
| 212 |
+
__convert_pyaddr_to_sockaddr(self._family, addr,
|
| 213 |
+
<system.sockaddr*>&saddr_st)
|
| 214 |
+
except (ValueError, TypeError):
|
| 215 |
+
raise
|
| 216 |
+
except Exception:
|
| 217 |
+
raise ValueError(
|
| 218 |
+
f'{addr!r}: socket family mismatch or '
|
| 219 |
+
f'a DNS lookup is required')
|
| 220 |
+
saddr = <system.sockaddr*>(&saddr_st)
|
| 221 |
+
|
| 222 |
+
if self._get_write_buffer_size() == 0:
|
| 223 |
+
PyObject_GetBuffer(data, &try_pybuf, PyBUF_SIMPLE)
|
| 224 |
+
try_uvbuf.base = <char*>try_pybuf.buf
|
| 225 |
+
try_uvbuf.len = try_pybuf.len
|
| 226 |
+
err = uv.uv_udp_try_send(<uv.uv_udp_t*>self._handle,
|
| 227 |
+
&try_uvbuf,
|
| 228 |
+
1,
|
| 229 |
+
saddr)
|
| 230 |
+
PyBuffer_Release(&try_pybuf)
|
| 231 |
+
else:
|
| 232 |
+
err = uv.UV_EAGAIN
|
| 233 |
+
|
| 234 |
+
if err == uv.UV_EAGAIN:
|
| 235 |
+
ctx = _UDPSendContext.new(self, data)
|
| 236 |
+
err = uv.uv_udp_send(&ctx.req,
|
| 237 |
+
<uv.uv_udp_t*>self._handle,
|
| 238 |
+
&ctx.uv_buf,
|
| 239 |
+
1,
|
| 240 |
+
saddr,
|
| 241 |
+
__uv_udp_on_send)
|
| 242 |
+
|
| 243 |
+
if err < 0:
|
| 244 |
+
ctx.close()
|
| 245 |
+
|
| 246 |
+
exc = convert_error(err)
|
| 247 |
+
if isinstance(exc, OSError):
|
| 248 |
+
run_in_context1(self.context.copy(), self._protocol.error_received, exc)
|
| 249 |
+
else:
|
| 250 |
+
self._fatal_error(exc, True)
|
| 251 |
+
else:
|
| 252 |
+
self._maybe_pause_protocol()
|
| 253 |
+
|
| 254 |
+
else:
|
| 255 |
+
self._on_sent(convert_error(err) if err < 0 else None, self.context.copy())
|
| 256 |
+
|
| 257 |
+
cdef _on_receive(self, bytes data, object exc, object addr):
|
| 258 |
+
if exc is None:
|
| 259 |
+
run_in_context2(
|
| 260 |
+
self.context, self._protocol.datagram_received, data, addr,
|
| 261 |
+
)
|
| 262 |
+
else:
|
| 263 |
+
run_in_context1(self.context, self._protocol.error_received, exc)
|
| 264 |
+
|
| 265 |
+
cdef _on_sent(self, object exc, object context=None):
|
| 266 |
+
if exc is not None:
|
| 267 |
+
if isinstance(exc, OSError):
|
| 268 |
+
if context is None:
|
| 269 |
+
context = self.context
|
| 270 |
+
run_in_context1(context, self._protocol.error_received, exc)
|
| 271 |
+
else:
|
| 272 |
+
self._fatal_error(
|
| 273 |
+
exc, False, 'Fatal write error on datagram transport')
|
| 274 |
+
|
| 275 |
+
self._maybe_resume_protocol()
|
| 276 |
+
if not self._get_write_buffer_size():
|
| 277 |
+
if self._closing:
|
| 278 |
+
self._schedule_call_connection_lost(None)
|
| 279 |
+
|
| 280 |
+
# === Public API ===
|
| 281 |
+
|
| 282 |
+
def sendto(self, data, addr=None):
|
| 283 |
+
if not data:
|
| 284 |
+
# Replicating asyncio logic here.
|
| 285 |
+
return
|
| 286 |
+
|
| 287 |
+
if self._address:
|
| 288 |
+
if addr not in (None, self._address):
|
| 289 |
+
# Replicating asyncio logic here.
|
| 290 |
+
raise ValueError(
|
| 291 |
+
'Invalid address: must be None or %s' % (self._address,))
|
| 292 |
+
|
| 293 |
+
# Instead of setting addr to self._address below like what asyncio
|
| 294 |
+
# does, we depend on previous uv_udp_connect() to set the address
|
| 295 |
+
addr = None
|
| 296 |
+
|
| 297 |
+
if self._conn_lost:
|
| 298 |
+
# Replicating asyncio logic here.
|
| 299 |
+
if self._conn_lost >= LOG_THRESHOLD_FOR_CONNLOST_WRITES:
|
| 300 |
+
aio_logger.warning('socket.send() raised exception.')
|
| 301 |
+
self._conn_lost += 1
|
| 302 |
+
return
|
| 303 |
+
|
| 304 |
+
self._send(data, addr)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
cdef void __uv_udp_on_receive(
|
| 308 |
+
uv.uv_udp_t* handle,
|
| 309 |
+
ssize_t nread,
|
| 310 |
+
const uv.uv_buf_t* buf,
|
| 311 |
+
const system.sockaddr* addr,
|
| 312 |
+
unsigned flags
|
| 313 |
+
) noexcept with gil:
|
| 314 |
+
|
| 315 |
+
if __ensure_handle_data(<uv.uv_handle_t*>handle,
|
| 316 |
+
"UDPTransport receive callback") == 0:
|
| 317 |
+
return
|
| 318 |
+
|
| 319 |
+
cdef:
|
| 320 |
+
UDPTransport udp = <UDPTransport>handle.data
|
| 321 |
+
Loop loop = udp._loop
|
| 322 |
+
bytes data
|
| 323 |
+
object pyaddr
|
| 324 |
+
|
| 325 |
+
# It's OK to free the buffer early, since nothing will
|
| 326 |
+
# be able to touch it until this method is done.
|
| 327 |
+
__loop_free_buffer(loop)
|
| 328 |
+
|
| 329 |
+
if udp._closed:
|
| 330 |
+
# The handle was closed, there is no reason to
|
| 331 |
+
# do any work now.
|
| 332 |
+
udp.__receiving_stopped() # Just in case.
|
| 333 |
+
return
|
| 334 |
+
|
| 335 |
+
if addr is NULL and nread == 0:
|
| 336 |
+
# From libuv docs:
|
| 337 |
+
# addr: struct sockaddr* containing the address
|
| 338 |
+
# of the sender. Can be NULL. Valid for the duration
|
| 339 |
+
# of the callback only.
|
| 340 |
+
# [...]
|
| 341 |
+
# The receive callback will be called with
|
| 342 |
+
# nread == 0 and addr == NULL when there is
|
| 343 |
+
# nothing to read, and with nread == 0 and
|
| 344 |
+
# addr != NULL when an empty UDP packet is
|
| 345 |
+
# received.
|
| 346 |
+
return
|
| 347 |
+
|
| 348 |
+
if addr is NULL:
|
| 349 |
+
pyaddr = None
|
| 350 |
+
elif addr.sa_family == uv.AF_UNSPEC:
|
| 351 |
+
# https://github.com/MagicStack/uvloop/issues/304
|
| 352 |
+
if system.PLATFORM_IS_LINUX:
|
| 353 |
+
pyaddr = None
|
| 354 |
+
else:
|
| 355 |
+
pyaddr = ''
|
| 356 |
+
else:
|
| 357 |
+
try:
|
| 358 |
+
pyaddr = __convert_sockaddr_to_pyaddr(addr)
|
| 359 |
+
except BaseException as exc:
|
| 360 |
+
udp._error(exc, False)
|
| 361 |
+
return
|
| 362 |
+
|
| 363 |
+
if nread < 0:
|
| 364 |
+
exc = convert_error(nread)
|
| 365 |
+
udp._on_receive(None, exc, pyaddr)
|
| 366 |
+
return
|
| 367 |
+
|
| 368 |
+
if nread == 0:
|
| 369 |
+
data = b''
|
| 370 |
+
else:
|
| 371 |
+
data = loop._recv_buffer[:nread]
|
| 372 |
+
|
| 373 |
+
try:
|
| 374 |
+
udp._on_receive(data, None, pyaddr)
|
| 375 |
+
except BaseException as exc:
|
| 376 |
+
udp._error(exc, False)
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
cdef void __uv_udp_on_send(
|
| 380 |
+
uv.uv_udp_send_t* req,
|
| 381 |
+
int status,
|
| 382 |
+
) noexcept with gil:
|
| 383 |
+
|
| 384 |
+
if req.data is NULL:
|
| 385 |
+
# Shouldn't happen as:
|
| 386 |
+
# - _UDPSendContext does an extra INCREF in its 'init()'
|
| 387 |
+
# - _UDPSendContext holds a ref to the relevant UDPTransport
|
| 388 |
+
aio_logger.error(
|
| 389 |
+
'UVStream.write callback called with NULL req.data, status=%r',
|
| 390 |
+
status)
|
| 391 |
+
return
|
| 392 |
+
|
| 393 |
+
cdef:
|
| 394 |
+
_UDPSendContext ctx = <_UDPSendContext> req.data
|
| 395 |
+
UDPTransport udp = <UDPTransport>ctx.udp
|
| 396 |
+
|
| 397 |
+
ctx.close()
|
| 398 |
+
|
| 399 |
+
if status < 0:
|
| 400 |
+
exc = convert_error(status)
|
| 401 |
+
print(exc)
|
| 402 |
+
else:
|
| 403 |
+
exc = None
|
| 404 |
+
|
| 405 |
+
try:
|
| 406 |
+
udp._on_sent(exc)
|
| 407 |
+
except BaseException as exc:
|
| 408 |
+
udp._error(exc, False)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# flake8: noqa
|
| 2 |
+
|
| 3 |
+
# These have to be synced with the stdlib.pxi
|
| 4 |
+
import asyncio
|
| 5 |
+
import collections
|
| 6 |
+
import concurrent.futures
|
| 7 |
+
import errno
|
| 8 |
+
import functools
|
| 9 |
+
import gc
|
| 10 |
+
import inspect
|
| 11 |
+
import itertools
|
| 12 |
+
import os
|
| 13 |
+
import signal
|
| 14 |
+
import socket
|
| 15 |
+
import subprocess
|
| 16 |
+
import ssl
|
| 17 |
+
import stat
|
| 18 |
+
import sys
|
| 19 |
+
import threading
|
| 20 |
+
import traceback
|
| 21 |
+
import time
|
| 22 |
+
import warnings
|
| 23 |
+
import weakref
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/consts.pxi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef enum:
|
| 2 |
+
UV_STREAM_RECV_BUF_SIZE = 256000 # 250kb
|
| 3 |
+
|
| 4 |
+
FLOW_CONTROL_HIGH_WATER = 64 # KiB
|
| 5 |
+
FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB
|
| 6 |
+
FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB
|
| 7 |
+
|
| 8 |
+
DEFAULT_FREELIST_SIZE = 250
|
| 9 |
+
DNS_PYADDR_TO_SOCKADDR_CACHE_SIZE = 2048
|
| 10 |
+
|
| 11 |
+
DEBUG_STACK_DEPTH = 10
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
__PROCESS_DEBUG_SLEEP_AFTER_FORK = 1
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
|
| 18 |
+
SSL_READ_MAX_SIZE = 256 * 1024
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
cdef extern from *:
|
| 22 |
+
'''
|
| 23 |
+
// Number of seconds to wait for SSL handshake to complete
|
| 24 |
+
// The default timeout matches that of Nginx.
|
| 25 |
+
#define SSL_HANDSHAKE_TIMEOUT 60.0
|
| 26 |
+
|
| 27 |
+
// Number of seconds to wait for SSL shutdown to complete
|
| 28 |
+
// The default timeout mimics lingering_time
|
| 29 |
+
#define SSL_SHUTDOWN_TIMEOUT 30.0
|
| 30 |
+
'''
|
| 31 |
+
|
| 32 |
+
const float SSL_HANDSHAKE_TIMEOUT
|
| 33 |
+
const float SSL_SHUTDOWN_TIMEOUT
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/debug.pxd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef extern from "includes/debug.h":
|
| 2 |
+
|
| 3 |
+
cdef int UVLOOP_DEBUG
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/flowcontrol.pxd
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# flake8: noqa
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
cdef inline add_flowcontrol_defaults(high, low, int kb):
|
| 5 |
+
cdef int h, l
|
| 6 |
+
if high is None:
|
| 7 |
+
if low is None:
|
| 8 |
+
h = kb * 1024
|
| 9 |
+
else:
|
| 10 |
+
l = low
|
| 11 |
+
h = 4 * l
|
| 12 |
+
else:
|
| 13 |
+
h = high
|
| 14 |
+
if low is None:
|
| 15 |
+
l = h // 4
|
| 16 |
+
else:
|
| 17 |
+
l = low
|
| 18 |
+
|
| 19 |
+
if not h >= l >= 0:
|
| 20 |
+
raise ValueError('high (%r) must be >= low (%r) must be >= 0' %
|
| 21 |
+
(h, l))
|
| 22 |
+
|
| 23 |
+
return h, l
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/python.pxd
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef extern from "Python.h":
|
| 2 |
+
int PY_VERSION_HEX
|
| 3 |
+
|
| 4 |
+
unicode PyUnicode_FromString(const char *)
|
| 5 |
+
|
| 6 |
+
void* PyMem_RawMalloc(size_t n) nogil
|
| 7 |
+
void* PyMem_RawRealloc(void *p, size_t n) nogil
|
| 8 |
+
void* PyMem_RawCalloc(size_t nelem, size_t elsize) nogil
|
| 9 |
+
void PyMem_RawFree(void *p) nogil
|
| 10 |
+
|
| 11 |
+
object PyUnicode_EncodeFSDefault(object)
|
| 12 |
+
void PyErr_SetInterrupt() nogil
|
| 13 |
+
|
| 14 |
+
object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags)
|
| 15 |
+
object PyMemoryView_FromObject(object obj)
|
| 16 |
+
int PyMemoryView_Check(object obj)
|
| 17 |
+
|
| 18 |
+
cdef enum:
|
| 19 |
+
PyBUF_WRITE
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
cdef extern from "includes/compat.h":
|
| 23 |
+
object Context_CopyCurrent()
|
| 24 |
+
int Context_Enter(object) except -1
|
| 25 |
+
int Context_Exit(object) except -1
|
| 26 |
+
|
| 27 |
+
void PyOS_BeforeFork()
|
| 28 |
+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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# flake8: noqa
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import asyncio, asyncio.log, asyncio.base_events, \
|
| 5 |
+
asyncio.sslproto, asyncio.coroutines, \
|
| 6 |
+
asyncio.futures, asyncio.transports
|
| 7 |
+
import collections.abc
|
| 8 |
+
import concurrent.futures
|
| 9 |
+
import errno
|
| 10 |
+
import functools
|
| 11 |
+
import gc
|
| 12 |
+
import inspect
|
| 13 |
+
import itertools
|
| 14 |
+
import os
|
| 15 |
+
import signal
|
| 16 |
+
import socket
|
| 17 |
+
import subprocess
|
| 18 |
+
import ssl
|
| 19 |
+
import stat
|
| 20 |
+
import sys
|
| 21 |
+
import threading
|
| 22 |
+
import traceback
|
| 23 |
+
import time
|
| 24 |
+
import warnings
|
| 25 |
+
import weakref
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
cdef aio_get_event_loop = asyncio.get_event_loop
|
| 29 |
+
cdef aio_CancelledError = asyncio.CancelledError
|
| 30 |
+
cdef aio_InvalidStateError = asyncio.InvalidStateError
|
| 31 |
+
cdef aio_TimeoutError = asyncio.TimeoutError
|
| 32 |
+
cdef aio_Future = asyncio.Future
|
| 33 |
+
cdef aio_Task = asyncio.Task
|
| 34 |
+
cdef aio_ensure_future = asyncio.ensure_future
|
| 35 |
+
cdef aio_gather = asyncio.gather
|
| 36 |
+
cdef aio_wait = asyncio.wait
|
| 37 |
+
cdef aio_wrap_future = asyncio.wrap_future
|
| 38 |
+
cdef aio_logger = asyncio.log.logger
|
| 39 |
+
cdef aio_iscoroutine = asyncio.iscoroutine
|
| 40 |
+
cdef aio_iscoroutinefunction = asyncio.iscoroutinefunction
|
| 41 |
+
cdef aio_BaseProtocol = asyncio.BaseProtocol
|
| 42 |
+
cdef aio_Protocol = asyncio.Protocol
|
| 43 |
+
cdef aio_isfuture = getattr(asyncio, 'isfuture', None)
|
| 44 |
+
cdef aio_get_running_loop = getattr(asyncio, '_get_running_loop', None)
|
| 45 |
+
cdef aio_set_running_loop = getattr(asyncio, '_set_running_loop', None)
|
| 46 |
+
cdef aio_debug_wrapper = getattr(asyncio.coroutines, 'debug_wrapper', None)
|
| 47 |
+
cdef aio_AbstractChildWatcher = getattr(asyncio, "AbstractChildWatcher", ())
|
| 48 |
+
cdef aio_Transport = asyncio.Transport
|
| 49 |
+
cdef aio_FlowControlMixin = asyncio.transports._FlowControlMixin
|
| 50 |
+
|
| 51 |
+
cdef col_deque = collections.deque
|
| 52 |
+
cdef col_Iterable = collections.abc.Iterable
|
| 53 |
+
cdef col_Counter = collections.Counter
|
| 54 |
+
cdef col_OrderedDict = collections.OrderedDict
|
| 55 |
+
|
| 56 |
+
cdef cc_ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor
|
| 57 |
+
cdef cc_Future = concurrent.futures.Future
|
| 58 |
+
|
| 59 |
+
cdef errno_EBADF = errno.EBADF
|
| 60 |
+
cdef errno_EINVAL = errno.EINVAL
|
| 61 |
+
|
| 62 |
+
cdef ft_partial = functools.partial
|
| 63 |
+
|
| 64 |
+
cdef gc_disable = gc.disable
|
| 65 |
+
|
| 66 |
+
cdef iter_chain = itertools.chain
|
| 67 |
+
cdef inspect_isgenerator = inspect.isgenerator
|
| 68 |
+
|
| 69 |
+
cdef int has_IPV6_V6ONLY = hasattr(socket, 'IPV6_V6ONLY')
|
| 70 |
+
cdef int IPV6_V6ONLY = getattr(socket, 'IPV6_V6ONLY', -1)
|
| 71 |
+
cdef int has_SO_REUSEPORT = hasattr(socket, 'SO_REUSEPORT')
|
| 72 |
+
cdef int SO_REUSEPORT = getattr(socket, 'SO_REUSEPORT', 0)
|
| 73 |
+
cdef int SO_BROADCAST = getattr(socket, 'SO_BROADCAST')
|
| 74 |
+
cdef int SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', -1)
|
| 75 |
+
cdef int socket_AI_CANONNAME = getattr(socket, 'AI_CANONNAME')
|
| 76 |
+
|
| 77 |
+
cdef socket_gaierror = socket.gaierror
|
| 78 |
+
cdef socket_error = socket.error
|
| 79 |
+
cdef socket_timeout = socket.timeout
|
| 80 |
+
cdef socket_socket = socket.socket
|
| 81 |
+
cdef socket_socketpair = socket.socketpair
|
| 82 |
+
cdef socket_getservbyname = socket.getservbyname
|
| 83 |
+
cdef socket_AddressFamily = socket.AddressFamily
|
| 84 |
+
cdef socket_SocketKind = socket.SocketKind
|
| 85 |
+
|
| 86 |
+
cdef int socket_EAI_ADDRFAMILY = getattr(socket, 'EAI_ADDRFAMILY', -1)
|
| 87 |
+
cdef int socket_EAI_AGAIN = getattr(socket, 'EAI_AGAIN', -1)
|
| 88 |
+
cdef int socket_EAI_BADFLAGS = getattr(socket, 'EAI_BADFLAGS', -1)
|
| 89 |
+
cdef int socket_EAI_BADHINTS = getattr(socket, 'EAI_BADHINTS', -1)
|
| 90 |
+
cdef int socket_EAI_CANCELED = getattr(socket, 'EAI_CANCELED', -1)
|
| 91 |
+
cdef int socket_EAI_FAIL = getattr(socket, 'EAI_FAIL', -1)
|
| 92 |
+
cdef int socket_EAI_FAMILY = getattr(socket, 'EAI_FAMILY', -1)
|
| 93 |
+
cdef int socket_EAI_MEMORY = getattr(socket, 'EAI_MEMORY', -1)
|
| 94 |
+
cdef int socket_EAI_NODATA = getattr(socket, 'EAI_NODATA', -1)
|
| 95 |
+
cdef int socket_EAI_NONAME = getattr(socket, 'EAI_NONAME', -1)
|
| 96 |
+
cdef int socket_EAI_OVERFLOW = getattr(socket, 'EAI_OVERFLOW', -1)
|
| 97 |
+
cdef int socket_EAI_PROTOCOL = getattr(socket, 'EAI_PROTOCOL', -1)
|
| 98 |
+
cdef int socket_EAI_SERVICE = getattr(socket, 'EAI_SERVICE', -1)
|
| 99 |
+
cdef int socket_EAI_SOCKTYPE = getattr(socket, 'EAI_SOCKTYPE', -1)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
cdef str os_name = os.name
|
| 103 |
+
cdef os_environ = os.environ
|
| 104 |
+
cdef os_dup = os.dup
|
| 105 |
+
cdef os_set_inheritable = os.set_inheritable
|
| 106 |
+
cdef os_get_inheritable = os.get_inheritable
|
| 107 |
+
cdef os_close = os.close
|
| 108 |
+
cdef os_open = os.open
|
| 109 |
+
cdef os_devnull = os.devnull
|
| 110 |
+
cdef os_O_RDWR = os.O_RDWR
|
| 111 |
+
cdef os_pipe = os.pipe
|
| 112 |
+
cdef os_read = os.read
|
| 113 |
+
cdef os_remove = os.remove
|
| 114 |
+
cdef os_stat = os.stat
|
| 115 |
+
cdef os_unlink = os.unlink
|
| 116 |
+
cdef os_fspath = os.fspath
|
| 117 |
+
|
| 118 |
+
cdef stat_S_ISSOCK = stat.S_ISSOCK
|
| 119 |
+
|
| 120 |
+
cdef sys_ignore_environment = sys.flags.ignore_environment
|
| 121 |
+
cdef sys_dev_mode = sys.flags.dev_mode
|
| 122 |
+
cdef sys_exc_info = sys.exc_info
|
| 123 |
+
cdef sys_set_coroutine_wrapper = getattr(sys, 'set_coroutine_wrapper', None)
|
| 124 |
+
cdef sys_get_coroutine_wrapper = getattr(sys, 'get_coroutine_wrapper', None)
|
| 125 |
+
cdef sys_getframe = sys._getframe
|
| 126 |
+
cdef sys_version_info = sys.version_info
|
| 127 |
+
cdef sys_getfilesystemencoding = sys.getfilesystemencoding
|
| 128 |
+
cdef str sys_platform = sys.platform
|
| 129 |
+
|
| 130 |
+
cdef ssl_SSLContext = ssl.SSLContext
|
| 131 |
+
cdef ssl_MemoryBIO = ssl.MemoryBIO
|
| 132 |
+
cdef ssl_create_default_context = ssl.create_default_context
|
| 133 |
+
cdef ssl_SSLError = ssl.SSLError
|
| 134 |
+
cdef ssl_SSLAgainErrors = (ssl.SSLWantReadError, ssl.SSLSyscallError)
|
| 135 |
+
cdef ssl_SSLZeroReturnError = ssl.SSLZeroReturnError
|
| 136 |
+
cdef ssl_CertificateError = ssl.CertificateError
|
| 137 |
+
cdef int ssl_SSL_ERROR_WANT_READ = ssl.SSL_ERROR_WANT_READ
|
| 138 |
+
cdef int ssl_SSL_ERROR_WANT_WRITE = ssl.SSL_ERROR_WANT_WRITE
|
| 139 |
+
cdef int ssl_SSL_ERROR_SYSCALL = ssl.SSL_ERROR_SYSCALL
|
| 140 |
+
|
| 141 |
+
cdef threading_Thread = threading.Thread
|
| 142 |
+
cdef threading_main_thread = threading.main_thread
|
| 143 |
+
|
| 144 |
+
cdef int subprocess_PIPE = subprocess.PIPE
|
| 145 |
+
cdef int subprocess_STDOUT = subprocess.STDOUT
|
| 146 |
+
cdef int subprocess_DEVNULL = subprocess.DEVNULL
|
| 147 |
+
cdef subprocess_SubprocessError = subprocess.SubprocessError
|
| 148 |
+
|
| 149 |
+
cdef int signal_NSIG = signal.NSIG
|
| 150 |
+
cdef signal_signal = signal.signal
|
| 151 |
+
cdef signal_siginterrupt = signal.siginterrupt
|
| 152 |
+
cdef signal_set_wakeup_fd = signal.set_wakeup_fd
|
| 153 |
+
cdef signal_default_int_handler = signal.default_int_handler
|
| 154 |
+
cdef signal_SIG_DFL = signal.SIG_DFL
|
| 155 |
+
|
| 156 |
+
cdef time_sleep = time.sleep
|
| 157 |
+
cdef time_monotonic = time.monotonic
|
| 158 |
+
|
| 159 |
+
cdef tb_StackSummary = traceback.StackSummary
|
| 160 |
+
cdef tb_walk_stack = traceback.walk_stack
|
| 161 |
+
cdef tb_format_list = traceback.format_list
|
| 162 |
+
|
| 163 |
+
cdef warnings_warn = warnings.warn
|
| 164 |
+
|
| 165 |
+
cdef weakref_WeakValueDictionary = weakref.WeakValueDictionary
|
| 166 |
+
cdef weakref_WeakSet = weakref.WeakSet
|
| 167 |
+
|
| 168 |
+
cdef py_inf = float('inf')
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
# Cython doesn't clean-up imported objects properly in Py3 mode,
|
| 172 |
+
# so we delete refs to all modules manually (except sys)
|
| 173 |
+
del asyncio, concurrent, collections, errno
|
| 174 |
+
del functools, inspect, itertools, socket, os, threading
|
| 175 |
+
del signal, subprocess, ssl
|
| 176 |
+
del time, traceback, warnings, weakref
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/system.pxd
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from libc.stdint cimport int8_t, uint64_t
|
| 2 |
+
|
| 3 |
+
cdef extern from "arpa/inet.h" nogil:
|
| 4 |
+
|
| 5 |
+
int ntohl(int)
|
| 6 |
+
int htonl(int)
|
| 7 |
+
int ntohs(int)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
cdef extern from "sys/socket.h" nogil:
|
| 11 |
+
|
| 12 |
+
struct sockaddr:
|
| 13 |
+
unsigned short sa_family
|
| 14 |
+
char sa_data[14]
|
| 15 |
+
|
| 16 |
+
struct addrinfo:
|
| 17 |
+
int ai_flags
|
| 18 |
+
int ai_family
|
| 19 |
+
int ai_socktype
|
| 20 |
+
int ai_protocol
|
| 21 |
+
size_t ai_addrlen
|
| 22 |
+
sockaddr* ai_addr
|
| 23 |
+
char* ai_canonname
|
| 24 |
+
addrinfo* ai_next
|
| 25 |
+
|
| 26 |
+
struct sockaddr_in:
|
| 27 |
+
unsigned short sin_family
|
| 28 |
+
unsigned short sin_port
|
| 29 |
+
# ...
|
| 30 |
+
|
| 31 |
+
struct sockaddr_in6:
|
| 32 |
+
unsigned short sin6_family
|
| 33 |
+
unsigned short sin6_port
|
| 34 |
+
unsigned long sin6_flowinfo
|
| 35 |
+
# ...
|
| 36 |
+
unsigned long sin6_scope_id
|
| 37 |
+
|
| 38 |
+
struct sockaddr_storage:
|
| 39 |
+
unsigned short ss_family
|
| 40 |
+
# ...
|
| 41 |
+
|
| 42 |
+
const char *gai_strerror(int errcode)
|
| 43 |
+
|
| 44 |
+
int socketpair(int domain, int type, int protocol, int socket_vector[2])
|
| 45 |
+
|
| 46 |
+
int setsockopt(int socket, int level, int option_name,
|
| 47 |
+
const void *option_value, int option_len)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
cdef extern from "sys/un.h" nogil:
|
| 51 |
+
|
| 52 |
+
struct sockaddr_un:
|
| 53 |
+
unsigned short sun_family
|
| 54 |
+
char* sun_path
|
| 55 |
+
# ...
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
cdef extern from "unistd.h" nogil:
|
| 59 |
+
|
| 60 |
+
ssize_t write(int fd, const void *buf, size_t count)
|
| 61 |
+
void _exit(int status)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
cdef extern from "pthread.h":
|
| 65 |
+
|
| 66 |
+
int pthread_atfork(
|
| 67 |
+
void (*prepare)(),
|
| 68 |
+
void (*parent)(),
|
| 69 |
+
void (*child)())
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
cdef extern from "includes/compat.h" nogil:
|
| 73 |
+
|
| 74 |
+
cdef int EWOULDBLOCK
|
| 75 |
+
|
| 76 |
+
cdef int PLATFORM_IS_APPLE
|
| 77 |
+
cdef int PLATFORM_IS_LINUX
|
| 78 |
+
|
| 79 |
+
struct epoll_event:
|
| 80 |
+
# We don't use the fields
|
| 81 |
+
pass
|
| 82 |
+
|
| 83 |
+
int EPOLL_CTL_DEL
|
| 84 |
+
int epoll_ctl(int epfd, int op, int fd, epoll_event *event)
|
| 85 |
+
object MakeUnixSockPyAddr(sockaddr_un *addr)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
cdef extern from "includes/fork_handler.h":
|
| 89 |
+
|
| 90 |
+
uint64_t MAIN_THREAD_ID
|
| 91 |
+
int8_t MAIN_THREAD_ID_SET
|
| 92 |
+
ctypedef void (*OnForkHandler)()
|
| 93 |
+
void handleAtFork()
|
| 94 |
+
void setForkHandler(OnForkHandler handler)
|
| 95 |
+
void resetForkHandler()
|
| 96 |
+
void setMainThreadID(uint64_t id)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/includes/uv.pxd
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from libc.stdint cimport uint16_t, uint32_t, uint64_t, int64_t
|
| 2 |
+
from posix.types cimport gid_t, uid_t
|
| 3 |
+
from posix.unistd cimport getuid
|
| 4 |
+
|
| 5 |
+
from . cimport system
|
| 6 |
+
|
| 7 |
+
# This is an internal enum UV_HANDLE_READABLE from uv-common.h, used only by
|
| 8 |
+
# handles/pipe.pyx to temporarily workaround a libuv issue libuv/libuv#2058,
|
| 9 |
+
# before there is a proper fix in libuv. In short, libuv disallowed feeding a
|
| 10 |
+
# write-only pipe to uv_read_start(), which was needed by uvloop to detect a
|
| 11 |
+
# broken pipe without having to send anything on the write-only end. We're
|
| 12 |
+
# setting UV_HANDLE_READABLE on pipe_t to workaround this limitation
|
| 13 |
+
# temporarily, please see also #317.
|
| 14 |
+
cdef enum:
|
| 15 |
+
UV_INTERNAL_HANDLE_READABLE = 0x00004000
|
| 16 |
+
|
| 17 |
+
cdef extern from "uv.h" nogil:
|
| 18 |
+
cdef int UV_TCP_IPV6ONLY
|
| 19 |
+
|
| 20 |
+
cdef int UV_EACCES
|
| 21 |
+
cdef int UV_EAGAIN
|
| 22 |
+
cdef int UV_EALREADY
|
| 23 |
+
cdef int UV_EBUSY
|
| 24 |
+
cdef int UV_ECONNABORTED
|
| 25 |
+
cdef int UV_ECONNREFUSED
|
| 26 |
+
cdef int UV_ECONNRESET
|
| 27 |
+
cdef int UV_ECANCELED
|
| 28 |
+
cdef int UV_EEXIST
|
| 29 |
+
cdef int UV_EINTR
|
| 30 |
+
cdef int UV_EINVAL
|
| 31 |
+
cdef int UV_EISDIR
|
| 32 |
+
cdef int UV_ENOENT
|
| 33 |
+
cdef int UV_EOF
|
| 34 |
+
cdef int UV_EPERM
|
| 35 |
+
cdef int UV_EPIPE
|
| 36 |
+
cdef int UV_ESHUTDOWN
|
| 37 |
+
cdef int UV_ESRCH
|
| 38 |
+
cdef int UV_ETIMEDOUT
|
| 39 |
+
cdef int UV_EBADF
|
| 40 |
+
cdef int UV_ENOBUFS
|
| 41 |
+
|
| 42 |
+
cdef int UV_EAI_ADDRFAMILY
|
| 43 |
+
cdef int UV_EAI_AGAIN
|
| 44 |
+
cdef int UV_EAI_BADFLAGS
|
| 45 |
+
cdef int UV_EAI_BADHINTS
|
| 46 |
+
cdef int UV_EAI_CANCELED
|
| 47 |
+
cdef int UV_EAI_FAIL
|
| 48 |
+
cdef int UV_EAI_FAMILY
|
| 49 |
+
cdef int UV_EAI_MEMORY
|
| 50 |
+
cdef int UV_EAI_NODATA
|
| 51 |
+
cdef int UV_EAI_NONAME
|
| 52 |
+
cdef int UV_EAI_OVERFLOW
|
| 53 |
+
cdef int UV_EAI_PROTOCOL
|
| 54 |
+
cdef int UV_EAI_SERVICE
|
| 55 |
+
cdef int UV_EAI_SOCKTYPE
|
| 56 |
+
|
| 57 |
+
cdef int SOL_SOCKET
|
| 58 |
+
cdef int SO_ERROR
|
| 59 |
+
cdef int SO_REUSEADDR
|
| 60 |
+
# use has_SO_REUSEPORT and SO_REUSEPORT in stdlib.pxi instead
|
| 61 |
+
cdef int AF_INET
|
| 62 |
+
cdef int AF_INET6
|
| 63 |
+
cdef int AF_UNIX
|
| 64 |
+
cdef int AF_UNSPEC
|
| 65 |
+
cdef int AI_PASSIVE
|
| 66 |
+
cdef int AI_NUMERICHOST
|
| 67 |
+
cdef int INET6_ADDRSTRLEN
|
| 68 |
+
cdef int IPPROTO_IPV6
|
| 69 |
+
cdef int SOCK_STREAM
|
| 70 |
+
cdef int SOCK_DGRAM
|
| 71 |
+
cdef int IPPROTO_TCP
|
| 72 |
+
cdef int IPPROTO_UDP
|
| 73 |
+
|
| 74 |
+
cdef int SIGINT
|
| 75 |
+
cdef int SIGHUP
|
| 76 |
+
cdef int SIGCHLD
|
| 77 |
+
cdef int SIGKILL
|
| 78 |
+
cdef int SIGTERM
|
| 79 |
+
|
| 80 |
+
ctypedef int uv_os_sock_t
|
| 81 |
+
ctypedef int uv_file
|
| 82 |
+
ctypedef int uv_os_fd_t
|
| 83 |
+
|
| 84 |
+
ctypedef struct uv_buf_t:
|
| 85 |
+
char* base
|
| 86 |
+
size_t len
|
| 87 |
+
|
| 88 |
+
ctypedef struct uv_loop_t:
|
| 89 |
+
void* data
|
| 90 |
+
# ...
|
| 91 |
+
|
| 92 |
+
ctypedef struct uv_handle_t:
|
| 93 |
+
void* data
|
| 94 |
+
uv_loop_t* loop
|
| 95 |
+
unsigned int flags
|
| 96 |
+
# ...
|
| 97 |
+
|
| 98 |
+
ctypedef struct uv_idle_t:
|
| 99 |
+
void* data
|
| 100 |
+
uv_loop_t* loop
|
| 101 |
+
# ...
|
| 102 |
+
|
| 103 |
+
ctypedef struct uv_check_t:
|
| 104 |
+
void* data
|
| 105 |
+
uv_loop_t* loop
|
| 106 |
+
# ...
|
| 107 |
+
|
| 108 |
+
ctypedef struct uv_signal_t:
|
| 109 |
+
void* data
|
| 110 |
+
uv_loop_t* loop
|
| 111 |
+
# ...
|
| 112 |
+
|
| 113 |
+
ctypedef struct uv_async_t:
|
| 114 |
+
void* data
|
| 115 |
+
uv_loop_t* loop
|
| 116 |
+
# ...
|
| 117 |
+
|
| 118 |
+
ctypedef struct uv_timer_t:
|
| 119 |
+
void* data
|
| 120 |
+
uv_loop_t* loop
|
| 121 |
+
# ...
|
| 122 |
+
|
| 123 |
+
ctypedef struct uv_stream_t:
|
| 124 |
+
void* data
|
| 125 |
+
size_t write_queue_size
|
| 126 |
+
uv_loop_t* loop
|
| 127 |
+
# ...
|
| 128 |
+
|
| 129 |
+
ctypedef struct uv_tcp_t:
|
| 130 |
+
void* data
|
| 131 |
+
uv_loop_t* loop
|
| 132 |
+
# ...
|
| 133 |
+
|
| 134 |
+
ctypedef struct uv_pipe_t:
|
| 135 |
+
void* data
|
| 136 |
+
uv_loop_t* loop
|
| 137 |
+
# ...
|
| 138 |
+
|
| 139 |
+
ctypedef struct uv_udp_t:
|
| 140 |
+
void* data
|
| 141 |
+
uv_loop_t* loop
|
| 142 |
+
size_t send_queue_size
|
| 143 |
+
size_t send_queue_count
|
| 144 |
+
# ...
|
| 145 |
+
|
| 146 |
+
ctypedef struct uv_udp_send_t:
|
| 147 |
+
void* data
|
| 148 |
+
uv_udp_t* handle
|
| 149 |
+
|
| 150 |
+
ctypedef struct uv_poll_t:
|
| 151 |
+
void* data
|
| 152 |
+
uv_loop_t* loop
|
| 153 |
+
# ...
|
| 154 |
+
|
| 155 |
+
ctypedef struct uv_req_t:
|
| 156 |
+
# Only cancellation of uv_fs_t, uv_getaddrinfo_t,
|
| 157 |
+
# uv_getnameinfo_t and uv_work_t requests is
|
| 158 |
+
# currently supported.
|
| 159 |
+
void* data
|
| 160 |
+
uv_req_type type
|
| 161 |
+
# ...
|
| 162 |
+
|
| 163 |
+
ctypedef struct uv_connect_t:
|
| 164 |
+
void* data
|
| 165 |
+
|
| 166 |
+
ctypedef struct uv_getaddrinfo_t:
|
| 167 |
+
void* data
|
| 168 |
+
# ...
|
| 169 |
+
|
| 170 |
+
ctypedef struct uv_getnameinfo_t:
|
| 171 |
+
void* data
|
| 172 |
+
# ...
|
| 173 |
+
|
| 174 |
+
ctypedef struct uv_write_t:
|
| 175 |
+
void* data
|
| 176 |
+
# ...
|
| 177 |
+
|
| 178 |
+
ctypedef struct uv_shutdown_t:
|
| 179 |
+
void* data
|
| 180 |
+
# ...
|
| 181 |
+
|
| 182 |
+
ctypedef struct uv_process_t:
|
| 183 |
+
void* data
|
| 184 |
+
int pid
|
| 185 |
+
# ...
|
| 186 |
+
|
| 187 |
+
ctypedef struct uv_fs_event_t:
|
| 188 |
+
void* data
|
| 189 |
+
# ...
|
| 190 |
+
|
| 191 |
+
ctypedef enum uv_req_type:
|
| 192 |
+
UV_UNKNOWN_REQ = 0,
|
| 193 |
+
UV_REQ,
|
| 194 |
+
UV_CONNECT,
|
| 195 |
+
UV_WRITE,
|
| 196 |
+
UV_SHUTDOWN,
|
| 197 |
+
UV_UDP_SEND,
|
| 198 |
+
UV_FS,
|
| 199 |
+
UV_WORK,
|
| 200 |
+
UV_GETADDRINFO,
|
| 201 |
+
UV_GETNAMEINFO,
|
| 202 |
+
UV_REQ_TYPE_PRIVATE,
|
| 203 |
+
UV_REQ_TYPE_MAX
|
| 204 |
+
|
| 205 |
+
ctypedef enum uv_run_mode:
|
| 206 |
+
UV_RUN_DEFAULT = 0,
|
| 207 |
+
UV_RUN_ONCE,
|
| 208 |
+
UV_RUN_NOWAIT
|
| 209 |
+
|
| 210 |
+
ctypedef enum uv_poll_event:
|
| 211 |
+
UV_READABLE = 1,
|
| 212 |
+
UV_WRITABLE = 2,
|
| 213 |
+
UV_DISCONNECT = 4
|
| 214 |
+
|
| 215 |
+
ctypedef enum uv_udp_flags:
|
| 216 |
+
UV_UDP_IPV6ONLY = 1,
|
| 217 |
+
UV_UDP_PARTIAL = 2
|
| 218 |
+
|
| 219 |
+
ctypedef enum uv_membership:
|
| 220 |
+
UV_LEAVE_GROUP = 0,
|
| 221 |
+
UV_JOIN_GROUP
|
| 222 |
+
|
| 223 |
+
cdef enum uv_fs_event:
|
| 224 |
+
UV_RENAME = 1,
|
| 225 |
+
UV_CHANGE = 2
|
| 226 |
+
|
| 227 |
+
const char* uv_strerror(int err)
|
| 228 |
+
const char* uv_err_name(int err)
|
| 229 |
+
|
| 230 |
+
ctypedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg) with gil
|
| 231 |
+
|
| 232 |
+
ctypedef void (*uv_close_cb)(uv_handle_t* handle) with gil
|
| 233 |
+
ctypedef void (*uv_idle_cb)(uv_idle_t* handle) with gil
|
| 234 |
+
ctypedef void (*uv_check_cb)(uv_check_t* handle) with gil
|
| 235 |
+
ctypedef void (*uv_signal_cb)(uv_signal_t* handle, int signum) with gil
|
| 236 |
+
ctypedef void (*uv_async_cb)(uv_async_t* handle) with gil
|
| 237 |
+
ctypedef void (*uv_timer_cb)(uv_timer_t* handle) with gil
|
| 238 |
+
ctypedef void (*uv_connection_cb)(uv_stream_t* server, int status) with gil
|
| 239 |
+
ctypedef void (*uv_alloc_cb)(uv_handle_t* handle,
|
| 240 |
+
size_t suggested_size,
|
| 241 |
+
uv_buf_t* buf) with gil
|
| 242 |
+
ctypedef void (*uv_read_cb)(uv_stream_t* stream,
|
| 243 |
+
ssize_t nread,
|
| 244 |
+
const uv_buf_t* buf) with gil
|
| 245 |
+
ctypedef void (*uv_write_cb)(uv_write_t* req, int status) with gil
|
| 246 |
+
ctypedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
|
| 247 |
+
int status,
|
| 248 |
+
system.addrinfo* res) with gil
|
| 249 |
+
ctypedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req,
|
| 250 |
+
int status,
|
| 251 |
+
const char* hostname,
|
| 252 |
+
const char* service) with gil
|
| 253 |
+
ctypedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status) with gil
|
| 254 |
+
ctypedef void (*uv_poll_cb)(uv_poll_t* handle,
|
| 255 |
+
int status, int events) with gil
|
| 256 |
+
|
| 257 |
+
ctypedef void (*uv_connect_cb)(uv_connect_t* req, int status) with gil
|
| 258 |
+
|
| 259 |
+
ctypedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status) with gil
|
| 260 |
+
ctypedef void (*uv_udp_recv_cb)(uv_udp_t* handle,
|
| 261 |
+
ssize_t nread,
|
| 262 |
+
const uv_buf_t* buf,
|
| 263 |
+
const system.sockaddr* addr,
|
| 264 |
+
unsigned flags) with gil
|
| 265 |
+
ctypedef void (*uv_fs_event_cb)(uv_fs_event_t* handle,
|
| 266 |
+
const char *filename,
|
| 267 |
+
int events,
|
| 268 |
+
int status) with gil
|
| 269 |
+
|
| 270 |
+
# Generic request functions
|
| 271 |
+
int uv_cancel(uv_req_t* req)
|
| 272 |
+
|
| 273 |
+
# Generic handler functions
|
| 274 |
+
int uv_is_active(const uv_handle_t* handle)
|
| 275 |
+
void uv_close(uv_handle_t* handle, uv_close_cb close_cb)
|
| 276 |
+
int uv_is_closing(const uv_handle_t* handle)
|
| 277 |
+
int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd)
|
| 278 |
+
void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg)
|
| 279 |
+
|
| 280 |
+
# Loop functions
|
| 281 |
+
int uv_loop_init(uv_loop_t* loop)
|
| 282 |
+
int uv_loop_close(uv_loop_t* loop)
|
| 283 |
+
int uv_loop_alive(uv_loop_t* loop)
|
| 284 |
+
int uv_loop_fork(uv_loop_t* loop)
|
| 285 |
+
uv_os_fd_t uv_backend_fd(uv_loop_t* loop)
|
| 286 |
+
|
| 287 |
+
void uv_update_time(uv_loop_t* loop)
|
| 288 |
+
uint64_t uv_now(const uv_loop_t*)
|
| 289 |
+
|
| 290 |
+
int uv_run(uv_loop_t*, uv_run_mode mode) nogil
|
| 291 |
+
void uv_stop(uv_loop_t*)
|
| 292 |
+
|
| 293 |
+
# Idle handler
|
| 294 |
+
int uv_idle_init(uv_loop_t*, uv_idle_t* idle)
|
| 295 |
+
int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb)
|
| 296 |
+
int uv_idle_stop(uv_idle_t* idle)
|
| 297 |
+
|
| 298 |
+
# Check handler
|
| 299 |
+
int uv_check_init(uv_loop_t*, uv_check_t* idle)
|
| 300 |
+
int uv_check_start(uv_check_t* check, uv_check_cb cb)
|
| 301 |
+
int uv_check_stop(uv_check_t* check)
|
| 302 |
+
|
| 303 |
+
# Signal handler
|
| 304 |
+
int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle)
|
| 305 |
+
int uv_signal_start(uv_signal_t* handle,
|
| 306 |
+
uv_signal_cb signal_cb,
|
| 307 |
+
int signum)
|
| 308 |
+
int uv_signal_stop(uv_signal_t* handle)
|
| 309 |
+
|
| 310 |
+
# Async handler
|
| 311 |
+
int uv_async_init(uv_loop_t*,
|
| 312 |
+
uv_async_t* async_,
|
| 313 |
+
uv_async_cb async_cb)
|
| 314 |
+
int uv_async_send(uv_async_t* async_)
|
| 315 |
+
|
| 316 |
+
# Timer handler
|
| 317 |
+
int uv_timer_init(uv_loop_t*, uv_timer_t* handle)
|
| 318 |
+
int uv_timer_start(uv_timer_t* handle,
|
| 319 |
+
uv_timer_cb cb,
|
| 320 |
+
uint64_t timeout,
|
| 321 |
+
uint64_t repeat)
|
| 322 |
+
int uv_timer_stop(uv_timer_t* handle)
|
| 323 |
+
|
| 324 |
+
# DNS
|
| 325 |
+
int uv_getaddrinfo(uv_loop_t* loop,
|
| 326 |
+
uv_getaddrinfo_t* req,
|
| 327 |
+
uv_getaddrinfo_cb getaddrinfo_cb,
|
| 328 |
+
const char* node,
|
| 329 |
+
const char* service,
|
| 330 |
+
const system.addrinfo* hints)
|
| 331 |
+
|
| 332 |
+
void uv_freeaddrinfo(system.addrinfo* ai)
|
| 333 |
+
|
| 334 |
+
int uv_getnameinfo(uv_loop_t* loop,
|
| 335 |
+
uv_getnameinfo_t* req,
|
| 336 |
+
uv_getnameinfo_cb getnameinfo_cb,
|
| 337 |
+
const system.sockaddr* addr,
|
| 338 |
+
int flags)
|
| 339 |
+
|
| 340 |
+
int uv_ip4_name(const system.sockaddr_in* src, char* dst, size_t size)
|
| 341 |
+
int uv_ip6_name(const system.sockaddr_in6* src, char* dst, size_t size)
|
| 342 |
+
|
| 343 |
+
# Streams
|
| 344 |
+
|
| 345 |
+
int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb)
|
| 346 |
+
int uv_accept(uv_stream_t* server, uv_stream_t* client)
|
| 347 |
+
int uv_read_start(uv_stream_t* stream,
|
| 348 |
+
uv_alloc_cb alloc_cb,
|
| 349 |
+
uv_read_cb read_cb)
|
| 350 |
+
int uv_read_stop(uv_stream_t*)
|
| 351 |
+
int uv_write(uv_write_t* req, uv_stream_t* handle,
|
| 352 |
+
uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
|
| 353 |
+
|
| 354 |
+
int uv_try_write(uv_stream_t* handle, uv_buf_t bufs[], unsigned int nbufs)
|
| 355 |
+
|
| 356 |
+
int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb)
|
| 357 |
+
|
| 358 |
+
int uv_is_readable(const uv_stream_t* handle)
|
| 359 |
+
int uv_is_writable(const uv_stream_t* handle)
|
| 360 |
+
|
| 361 |
+
# TCP
|
| 362 |
+
|
| 363 |
+
int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags)
|
| 364 |
+
int uv_tcp_nodelay(uv_tcp_t* handle, int enable)
|
| 365 |
+
int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay)
|
| 366 |
+
int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock)
|
| 367 |
+
int uv_tcp_bind(uv_tcp_t* handle, system.sockaddr* addr,
|
| 368 |
+
unsigned int flags)
|
| 369 |
+
|
| 370 |
+
int uv_tcp_getsockname(const uv_tcp_t* handle, system.sockaddr* name,
|
| 371 |
+
int* namelen)
|
| 372 |
+
int uv_tcp_getpeername(const uv_tcp_t* handle, system.sockaddr* name,
|
| 373 |
+
int* namelen)
|
| 374 |
+
|
| 375 |
+
int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
|
| 376 |
+
const system.sockaddr* addr, uv_connect_cb cb)
|
| 377 |
+
|
| 378 |
+
# Pipes
|
| 379 |
+
|
| 380 |
+
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc)
|
| 381 |
+
int uv_pipe_open(uv_pipe_t* handle, uv_os_fd_t file)
|
| 382 |
+
int uv_pipe_bind(uv_pipe_t* handle, const char* name)
|
| 383 |
+
|
| 384 |
+
void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
| 385 |
+
const char* name, uv_connect_cb cb)
|
| 386 |
+
|
| 387 |
+
# UDP
|
| 388 |
+
|
| 389 |
+
int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags)
|
| 390 |
+
int uv_udp_connect(uv_udp_t* handle, const system.sockaddr* addr)
|
| 391 |
+
int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock)
|
| 392 |
+
int uv_udp_bind(uv_udp_t* handle, const system.sockaddr* addr,
|
| 393 |
+
unsigned int flags)
|
| 394 |
+
int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle,
|
| 395 |
+
const uv_buf_t bufs[], unsigned int nbufs,
|
| 396 |
+
const system.sockaddr* addr, uv_udp_send_cb send_cb)
|
| 397 |
+
int uv_udp_try_send(uv_udp_t* handle,
|
| 398 |
+
const uv_buf_t bufs[], unsigned int nbufs,
|
| 399 |
+
const system.sockaddr* addr)
|
| 400 |
+
int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
|
| 401 |
+
uv_udp_recv_cb recv_cb)
|
| 402 |
+
int uv_udp_recv_stop(uv_udp_t* handle)
|
| 403 |
+
int uv_udp_set_broadcast(uv_udp_t* handle, int on)
|
| 404 |
+
|
| 405 |
+
# Polling
|
| 406 |
+
|
| 407 |
+
int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd)
|
| 408 |
+
int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
|
| 409 |
+
uv_os_sock_t socket)
|
| 410 |
+
int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb)
|
| 411 |
+
int uv_poll_stop(uv_poll_t* poll)
|
| 412 |
+
|
| 413 |
+
# FS Event
|
| 414 |
+
|
| 415 |
+
int uv_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle)
|
| 416 |
+
int uv_fs_event_start(uv_fs_event_t *handle, uv_fs_event_cb cb,
|
| 417 |
+
const char *path, unsigned int flags)
|
| 418 |
+
int uv_fs_event_stop(uv_fs_event_t *handle)
|
| 419 |
+
|
| 420 |
+
# Misc
|
| 421 |
+
|
| 422 |
+
ctypedef struct uv_timeval_t:
|
| 423 |
+
long tv_sec
|
| 424 |
+
long tv_usec
|
| 425 |
+
|
| 426 |
+
ctypedef struct uv_rusage_t:
|
| 427 |
+
uv_timeval_t ru_utime # user CPU time used
|
| 428 |
+
uv_timeval_t ru_stime # system CPU time used
|
| 429 |
+
uint64_t ru_maxrss # maximum resident set size
|
| 430 |
+
uint64_t ru_ixrss # integral shared memory size
|
| 431 |
+
uint64_t ru_idrss # integral unshared data size
|
| 432 |
+
uint64_t ru_isrss # integral unshared stack size
|
| 433 |
+
uint64_t ru_minflt # page reclaims (soft page faults)
|
| 434 |
+
uint64_t ru_majflt # page faults (hard page faults)
|
| 435 |
+
uint64_t ru_nswap # swaps
|
| 436 |
+
uint64_t ru_inblock # block input operations
|
| 437 |
+
uint64_t ru_oublock # block output operations
|
| 438 |
+
uint64_t ru_msgsnd # IPC messages sent
|
| 439 |
+
uint64_t ru_msgrcv # IPC messages received
|
| 440 |
+
uint64_t ru_nsignals # signals received
|
| 441 |
+
uint64_t ru_nvcsw # voluntary context switches
|
| 442 |
+
uint64_t ru_nivcsw # involuntary context switches
|
| 443 |
+
|
| 444 |
+
int uv_getrusage(uv_rusage_t* rusage)
|
| 445 |
+
|
| 446 |
+
int uv_ip4_addr(const char* ip, int port, system.sockaddr_in* addr)
|
| 447 |
+
int uv_ip6_addr(const char* ip, int port, system.sockaddr_in6* addr)
|
| 448 |
+
|
| 449 |
+
# Memory Allocation
|
| 450 |
+
|
| 451 |
+
ctypedef void* (*uv_malloc_func)(size_t size)
|
| 452 |
+
ctypedef void* (*uv_realloc_func)(void* ptr, size_t size)
|
| 453 |
+
ctypedef void* (*uv_calloc_func)(size_t count, size_t size)
|
| 454 |
+
ctypedef void (*uv_free_func)(void* ptr)
|
| 455 |
+
|
| 456 |
+
int uv_replace_allocator(uv_malloc_func malloc_func,
|
| 457 |
+
uv_realloc_func realloc_func,
|
| 458 |
+
uv_calloc_func calloc_func,
|
| 459 |
+
uv_free_func free_func)
|
| 460 |
+
|
| 461 |
+
# Process
|
| 462 |
+
|
| 463 |
+
ctypedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status,
|
| 464 |
+
int term_signal) with gil
|
| 465 |
+
|
| 466 |
+
ctypedef enum uv_process_flags:
|
| 467 |
+
UV_PROCESS_SETUID = 1,
|
| 468 |
+
UV_PROCESS_SETGID = 2,
|
| 469 |
+
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = 4,
|
| 470 |
+
UV_PROCESS_DETACHED = 8,
|
| 471 |
+
UV_PROCESS_WINDOWS_HIDE = 16
|
| 472 |
+
|
| 473 |
+
ctypedef enum uv_stdio_flags:
|
| 474 |
+
UV_IGNORE = 0x00,
|
| 475 |
+
UV_CREATE_PIPE = 0x01,
|
| 476 |
+
UV_INHERIT_FD = 0x02,
|
| 477 |
+
UV_INHERIT_STREAM = 0x04,
|
| 478 |
+
UV_READABLE_PIPE = 0x10,
|
| 479 |
+
UV_WRITABLE_PIPE = 0x20
|
| 480 |
+
|
| 481 |
+
ctypedef union uv_stdio_container_data_u:
|
| 482 |
+
uv_stream_t* stream
|
| 483 |
+
int fd
|
| 484 |
+
|
| 485 |
+
ctypedef struct uv_stdio_container_t:
|
| 486 |
+
uv_stdio_flags flags
|
| 487 |
+
uv_stdio_container_data_u data
|
| 488 |
+
|
| 489 |
+
ctypedef struct uv_process_options_t:
|
| 490 |
+
uv_exit_cb exit_cb
|
| 491 |
+
char* file
|
| 492 |
+
char** args
|
| 493 |
+
char** env
|
| 494 |
+
char* cwd
|
| 495 |
+
unsigned int flags
|
| 496 |
+
int stdio_count
|
| 497 |
+
uv_stdio_container_t* stdio
|
| 498 |
+
uid_t uid
|
| 499 |
+
gid_t gid
|
| 500 |
+
|
| 501 |
+
int uv_spawn(uv_loop_t* loop, uv_process_t* handle,
|
| 502 |
+
const uv_process_options_t* options)
|
| 503 |
+
|
| 504 |
+
int uv_process_kill(uv_process_t* handle, int signum)
|
| 505 |
+
|
| 506 |
+
unsigned int uv_version()
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.cpython-313-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:27132b45cb5dd0d9eee70d74d5cb7df7e5c19e92fc38b0a0b6a463ea9ab517aa
|
| 3 |
+
size 15743800
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pxd
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# cython: language_level=3
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
from .includes cimport uv
|
| 5 |
+
from .includes cimport system
|
| 6 |
+
|
| 7 |
+
from libc.stdint cimport uint64_t, uint32_t, int64_t
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
include "includes/consts.pxi"
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
cdef extern from *:
|
| 14 |
+
ctypedef int vint "volatile int"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
cdef class UVHandle
|
| 18 |
+
cdef class UVSocketHandle(UVHandle)
|
| 19 |
+
|
| 20 |
+
cdef class UVAsync(UVHandle)
|
| 21 |
+
cdef class UVTimer(UVHandle)
|
| 22 |
+
cdef class UVIdle(UVHandle)
|
| 23 |
+
|
| 24 |
+
cdef class UVBaseTransport(UVSocketHandle)
|
| 25 |
+
|
| 26 |
+
ctypedef object (*method_t)(object)
|
| 27 |
+
ctypedef object (*method1_t)(object, object)
|
| 28 |
+
ctypedef object (*method2_t)(object, object, object)
|
| 29 |
+
ctypedef object (*method3_t)(object, object, object, object)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
cdef class Loop:
|
| 33 |
+
cdef:
|
| 34 |
+
uv.uv_loop_t *uvloop
|
| 35 |
+
|
| 36 |
+
bint _coroutine_debug_set
|
| 37 |
+
int _coroutine_origin_tracking_saved_depth
|
| 38 |
+
|
| 39 |
+
public slow_callback_duration
|
| 40 |
+
|
| 41 |
+
readonly bint _closed
|
| 42 |
+
bint _debug
|
| 43 |
+
bint _running
|
| 44 |
+
bint _stopping
|
| 45 |
+
|
| 46 |
+
uint64_t _thread_id
|
| 47 |
+
|
| 48 |
+
object _task_factory
|
| 49 |
+
object _exception_handler
|
| 50 |
+
object _default_executor
|
| 51 |
+
object _ready
|
| 52 |
+
set _queued_streams, _executing_streams
|
| 53 |
+
Py_ssize_t _ready_len
|
| 54 |
+
|
| 55 |
+
set _servers
|
| 56 |
+
|
| 57 |
+
object _transports
|
| 58 |
+
set _processes
|
| 59 |
+
dict _fd_to_reader_fileobj
|
| 60 |
+
dict _fd_to_writer_fileobj
|
| 61 |
+
dict _unix_server_sockets
|
| 62 |
+
|
| 63 |
+
set _signals
|
| 64 |
+
dict _signal_handlers
|
| 65 |
+
object _ssock
|
| 66 |
+
object _csock
|
| 67 |
+
bint _listening_signals
|
| 68 |
+
int _old_signal_wakeup_id
|
| 69 |
+
|
| 70 |
+
set _timers
|
| 71 |
+
dict _polls
|
| 72 |
+
|
| 73 |
+
UVProcess active_process_handler
|
| 74 |
+
|
| 75 |
+
UVAsync handler_async
|
| 76 |
+
UVIdle handler_idle
|
| 77 |
+
UVCheck handler_check__exec_writes
|
| 78 |
+
|
| 79 |
+
object _last_error
|
| 80 |
+
|
| 81 |
+
cdef object __weakref__
|
| 82 |
+
|
| 83 |
+
object _asyncgens
|
| 84 |
+
bint _asyncgens_shutdown_called
|
| 85 |
+
|
| 86 |
+
bint _executor_shutdown_called
|
| 87 |
+
|
| 88 |
+
char _recv_buffer[UV_STREAM_RECV_BUF_SIZE]
|
| 89 |
+
bint _recv_buffer_in_use
|
| 90 |
+
|
| 91 |
+
# DEBUG fields
|
| 92 |
+
# True when compiled with DEBUG.
|
| 93 |
+
# Used only in unittests.
|
| 94 |
+
readonly bint _debug_cc
|
| 95 |
+
|
| 96 |
+
readonly object _debug_handles_total
|
| 97 |
+
readonly object _debug_handles_closed
|
| 98 |
+
readonly object _debug_handles_current
|
| 99 |
+
|
| 100 |
+
readonly uint64_t _debug_uv_handles_total
|
| 101 |
+
readonly uint64_t _debug_uv_handles_freed
|
| 102 |
+
|
| 103 |
+
readonly uint64_t _debug_cb_handles_total
|
| 104 |
+
readonly uint64_t _debug_cb_handles_count
|
| 105 |
+
readonly uint64_t _debug_cb_timer_handles_total
|
| 106 |
+
readonly uint64_t _debug_cb_timer_handles_count
|
| 107 |
+
|
| 108 |
+
readonly uint64_t _debug_stream_shutdown_errors_total
|
| 109 |
+
readonly uint64_t _debug_stream_listen_errors_total
|
| 110 |
+
|
| 111 |
+
readonly uint64_t _debug_stream_read_cb_total
|
| 112 |
+
readonly uint64_t _debug_stream_read_cb_errors_total
|
| 113 |
+
readonly uint64_t _debug_stream_read_eof_total
|
| 114 |
+
readonly uint64_t _debug_stream_read_eof_cb_errors_total
|
| 115 |
+
readonly uint64_t _debug_stream_read_errors_total
|
| 116 |
+
|
| 117 |
+
readonly uint64_t _debug_stream_write_tries
|
| 118 |
+
readonly uint64_t _debug_stream_write_errors_total
|
| 119 |
+
readonly uint64_t _debug_stream_write_ctx_total
|
| 120 |
+
readonly uint64_t _debug_stream_write_ctx_cnt
|
| 121 |
+
readonly uint64_t _debug_stream_write_cb_errors_total
|
| 122 |
+
|
| 123 |
+
readonly uint64_t _poll_read_events_total
|
| 124 |
+
readonly uint64_t _poll_read_cb_errors_total
|
| 125 |
+
readonly uint64_t _poll_write_events_total
|
| 126 |
+
readonly uint64_t _poll_write_cb_errors_total
|
| 127 |
+
|
| 128 |
+
readonly uint64_t _sock_try_write_total
|
| 129 |
+
|
| 130 |
+
readonly uint64_t _debug_exception_handler_cnt
|
| 131 |
+
|
| 132 |
+
cdef _init_debug_fields(self)
|
| 133 |
+
|
| 134 |
+
cdef _on_wake(self)
|
| 135 |
+
cdef _on_idle(self)
|
| 136 |
+
|
| 137 |
+
cdef __run(self, uv.uv_run_mode)
|
| 138 |
+
cdef _run(self, uv.uv_run_mode)
|
| 139 |
+
|
| 140 |
+
cdef _close(self)
|
| 141 |
+
cdef _stop(self, exc)
|
| 142 |
+
cdef uint64_t _time(self)
|
| 143 |
+
|
| 144 |
+
cdef inline _queue_write(self, UVStream stream)
|
| 145 |
+
cdef _exec_queued_writes(self)
|
| 146 |
+
|
| 147 |
+
cdef inline _call_soon(self, object callback, object args, object context)
|
| 148 |
+
cdef inline _append_ready_handle(self, Handle handle)
|
| 149 |
+
cdef inline _call_soon_handle(self, Handle handle)
|
| 150 |
+
|
| 151 |
+
cdef _call_later(self, uint64_t delay, object callback, object args,
|
| 152 |
+
object context)
|
| 153 |
+
|
| 154 |
+
cdef void _handle_exception(self, object ex)
|
| 155 |
+
|
| 156 |
+
cdef inline _is_main_thread(self)
|
| 157 |
+
|
| 158 |
+
cdef inline _new_future(self)
|
| 159 |
+
cdef inline _check_signal(self, sig)
|
| 160 |
+
cdef inline _check_closed(self)
|
| 161 |
+
cdef inline _check_thread(self)
|
| 162 |
+
|
| 163 |
+
cdef _getaddrinfo(self, object host, object port,
|
| 164 |
+
int family, int type,
|
| 165 |
+
int proto, int flags,
|
| 166 |
+
int unpack)
|
| 167 |
+
|
| 168 |
+
cdef _getnameinfo(self, system.sockaddr *addr, int flags)
|
| 169 |
+
|
| 170 |
+
cdef _track_transport(self, UVBaseTransport transport)
|
| 171 |
+
cdef _fileobj_to_fd(self, fileobj)
|
| 172 |
+
cdef _ensure_fd_no_transport(self, fd)
|
| 173 |
+
|
| 174 |
+
cdef _track_process(self, UVProcess proc)
|
| 175 |
+
cdef _untrack_process(self, UVProcess proc)
|
| 176 |
+
|
| 177 |
+
cdef _add_reader(self, fd, Handle handle)
|
| 178 |
+
cdef _has_reader(self, fd)
|
| 179 |
+
cdef _remove_reader(self, fd)
|
| 180 |
+
|
| 181 |
+
cdef _add_writer(self, fd, Handle handle)
|
| 182 |
+
cdef _has_writer(self, fd)
|
| 183 |
+
cdef _remove_writer(self, fd)
|
| 184 |
+
|
| 185 |
+
cdef _sock_recv(self, fut, sock, n)
|
| 186 |
+
cdef _sock_recv_into(self, fut, sock, buf)
|
| 187 |
+
cdef _sock_sendall(self, fut, sock, data)
|
| 188 |
+
cdef _sock_accept(self, fut, sock)
|
| 189 |
+
|
| 190 |
+
cdef _sock_connect(self, sock, address)
|
| 191 |
+
cdef _sock_connect_cb(self, fut, sock, address)
|
| 192 |
+
|
| 193 |
+
cdef _sock_set_reuseport(self, int fd)
|
| 194 |
+
|
| 195 |
+
cdef _setup_or_resume_signals(self)
|
| 196 |
+
cdef _shutdown_signals(self)
|
| 197 |
+
cdef _pause_signals(self)
|
| 198 |
+
|
| 199 |
+
cdef _handle_signal(self, sig)
|
| 200 |
+
cdef _read_from_self(self)
|
| 201 |
+
cdef inline _ceval_process_signals(self)
|
| 202 |
+
cdef _invoke_signals(self, bytes data)
|
| 203 |
+
|
| 204 |
+
cdef _set_coroutine_debug(self, bint enabled)
|
| 205 |
+
|
| 206 |
+
cdef _print_debug_info(self)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
include "cbhandles.pxd"
|
| 210 |
+
|
| 211 |
+
include "handles/handle.pxd"
|
| 212 |
+
include "handles/async_.pxd"
|
| 213 |
+
include "handles/idle.pxd"
|
| 214 |
+
include "handles/check.pxd"
|
| 215 |
+
include "handles/timer.pxd"
|
| 216 |
+
include "handles/poll.pxd"
|
| 217 |
+
include "handles/basetransport.pxd"
|
| 218 |
+
include "handles/stream.pxd"
|
| 219 |
+
include "handles/streamserver.pxd"
|
| 220 |
+
include "handles/tcp.pxd"
|
| 221 |
+
include "handles/pipe.pxd"
|
| 222 |
+
include "handles/process.pxd"
|
| 223 |
+
include "handles/fsevent.pxd"
|
| 224 |
+
|
| 225 |
+
include "request.pxd"
|
| 226 |
+
include "sslproto.pxd"
|
| 227 |
+
|
| 228 |
+
include "handles/udp.pxd"
|
| 229 |
+
|
| 230 |
+
include "server.pxd"
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pyi
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import ssl
|
| 3 |
+
import sys
|
| 4 |
+
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
| 5 |
+
from typing import (
|
| 6 |
+
IO,
|
| 7 |
+
Any,
|
| 8 |
+
Awaitable,
|
| 9 |
+
Callable,
|
| 10 |
+
Dict,
|
| 11 |
+
Generator,
|
| 12 |
+
List,
|
| 13 |
+
Optional,
|
| 14 |
+
Sequence,
|
| 15 |
+
Tuple,
|
| 16 |
+
TypeVar,
|
| 17 |
+
Union,
|
| 18 |
+
overload,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
_T = TypeVar('_T')
|
| 22 |
+
_Context = Dict[str, Any]
|
| 23 |
+
_ExceptionHandler = Callable[[asyncio.AbstractEventLoop, _Context], Any]
|
| 24 |
+
_SSLContext = Union[bool, None, ssl.SSLContext]
|
| 25 |
+
_ProtocolT = TypeVar("_ProtocolT", bound=asyncio.BaseProtocol)
|
| 26 |
+
|
| 27 |
+
class Loop:
|
| 28 |
+
def call_soon(
|
| 29 |
+
self, callback: Callable[..., Any], *args: Any, context: Optional[Any] = ...
|
| 30 |
+
) -> asyncio.Handle: ...
|
| 31 |
+
def call_soon_threadsafe(
|
| 32 |
+
self, callback: Callable[..., Any], *args: Any, context: Optional[Any] = ...
|
| 33 |
+
) -> asyncio.Handle: ...
|
| 34 |
+
def call_later(
|
| 35 |
+
self, delay: float, callback: Callable[..., Any], *args: Any, context: Optional[Any] = ...
|
| 36 |
+
) -> asyncio.TimerHandle: ...
|
| 37 |
+
def call_at(
|
| 38 |
+
self, when: float, callback: Callable[..., Any], *args: Any, context: Optional[Any] = ...
|
| 39 |
+
) -> asyncio.TimerHandle: ...
|
| 40 |
+
def time(self) -> float: ...
|
| 41 |
+
def stop(self) -> None: ...
|
| 42 |
+
def run_forever(self) -> None: ...
|
| 43 |
+
def close(self) -> None: ...
|
| 44 |
+
def get_debug(self) -> bool: ...
|
| 45 |
+
def set_debug(self, enabled: bool) -> None: ...
|
| 46 |
+
def is_running(self) -> bool: ...
|
| 47 |
+
def is_closed(self) -> bool: ...
|
| 48 |
+
def create_future(self) -> asyncio.Future[Any]: ...
|
| 49 |
+
def create_task(
|
| 50 |
+
self,
|
| 51 |
+
coro: Union[Awaitable[_T], Generator[Any, None, _T]],
|
| 52 |
+
*,
|
| 53 |
+
name: Optional[str] = ...,
|
| 54 |
+
) -> asyncio.Task[_T]: ...
|
| 55 |
+
def set_task_factory(
|
| 56 |
+
self,
|
| 57 |
+
factory: Optional[
|
| 58 |
+
Callable[[asyncio.AbstractEventLoop, Generator[Any, None, _T]], asyncio.Future[_T]]
|
| 59 |
+
],
|
| 60 |
+
) -> None: ...
|
| 61 |
+
def get_task_factory(
|
| 62 |
+
self,
|
| 63 |
+
) -> Optional[
|
| 64 |
+
Callable[[asyncio.AbstractEventLoop, Generator[Any, None, _T]], asyncio.Future[_T]]
|
| 65 |
+
]: ...
|
| 66 |
+
@overload
|
| 67 |
+
def run_until_complete(self, future: Generator[Any, None, _T]) -> _T: ...
|
| 68 |
+
@overload
|
| 69 |
+
def run_until_complete(self, future: Awaitable[_T]) -> _T: ...
|
| 70 |
+
async def getaddrinfo(
|
| 71 |
+
self,
|
| 72 |
+
host: Optional[Union[str, bytes]],
|
| 73 |
+
port: Optional[Union[str, bytes, int]],
|
| 74 |
+
*,
|
| 75 |
+
family: int = ...,
|
| 76 |
+
type: int = ...,
|
| 77 |
+
proto: int = ...,
|
| 78 |
+
flags: int = ...,
|
| 79 |
+
) -> List[
|
| 80 |
+
Tuple[
|
| 81 |
+
AddressFamily,
|
| 82 |
+
SocketKind,
|
| 83 |
+
int,
|
| 84 |
+
str,
|
| 85 |
+
Union[Tuple[str, int], Tuple[str, int, int, int]],
|
| 86 |
+
]
|
| 87 |
+
]: ...
|
| 88 |
+
async def getnameinfo(
|
| 89 |
+
self,
|
| 90 |
+
sockaddr: Union[
|
| 91 |
+
Tuple[str, int],
|
| 92 |
+
Tuple[str, int, int],
|
| 93 |
+
Tuple[str, int, int, int]
|
| 94 |
+
],
|
| 95 |
+
flags: int = ...,
|
| 96 |
+
) -> Tuple[str, str]: ...
|
| 97 |
+
async def start_tls(
|
| 98 |
+
self,
|
| 99 |
+
transport: asyncio.BaseTransport,
|
| 100 |
+
protocol: asyncio.BaseProtocol,
|
| 101 |
+
sslcontext: ssl.SSLContext,
|
| 102 |
+
*,
|
| 103 |
+
server_side: bool = ...,
|
| 104 |
+
server_hostname: Optional[str] = ...,
|
| 105 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 106 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 107 |
+
) -> asyncio.BaseTransport: ...
|
| 108 |
+
@overload
|
| 109 |
+
async def create_server(
|
| 110 |
+
self,
|
| 111 |
+
protocol_factory: asyncio.events._ProtocolFactory,
|
| 112 |
+
host: Optional[Union[str, Sequence[str]]] = ...,
|
| 113 |
+
port: int = ...,
|
| 114 |
+
*,
|
| 115 |
+
family: int = ...,
|
| 116 |
+
flags: int = ...,
|
| 117 |
+
sock: None = ...,
|
| 118 |
+
backlog: int = ...,
|
| 119 |
+
ssl: _SSLContext = ...,
|
| 120 |
+
reuse_address: Optional[bool] = ...,
|
| 121 |
+
reuse_port: Optional[bool] = ...,
|
| 122 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 123 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 124 |
+
start_serving: bool = ...,
|
| 125 |
+
) -> asyncio.AbstractServer: ...
|
| 126 |
+
@overload
|
| 127 |
+
async def create_server(
|
| 128 |
+
self,
|
| 129 |
+
protocol_factory: asyncio.events._ProtocolFactory,
|
| 130 |
+
host: None = ...,
|
| 131 |
+
port: None = ...,
|
| 132 |
+
*,
|
| 133 |
+
family: int = ...,
|
| 134 |
+
flags: int = ...,
|
| 135 |
+
sock: socket = ...,
|
| 136 |
+
backlog: int = ...,
|
| 137 |
+
ssl: _SSLContext = ...,
|
| 138 |
+
reuse_address: Optional[bool] = ...,
|
| 139 |
+
reuse_port: Optional[bool] = ...,
|
| 140 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 141 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 142 |
+
start_serving: bool = ...,
|
| 143 |
+
) -> asyncio.AbstractServer: ...
|
| 144 |
+
@overload
|
| 145 |
+
async def create_connection(
|
| 146 |
+
self,
|
| 147 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 148 |
+
host: str = ...,
|
| 149 |
+
port: int = ...,
|
| 150 |
+
*,
|
| 151 |
+
ssl: _SSLContext = ...,
|
| 152 |
+
family: int = ...,
|
| 153 |
+
proto: int = ...,
|
| 154 |
+
flags: int = ...,
|
| 155 |
+
sock: None = ...,
|
| 156 |
+
local_addr: Optional[Tuple[str, int]] = ...,
|
| 157 |
+
server_hostname: Optional[str] = ...,
|
| 158 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 159 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 160 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 161 |
+
@overload
|
| 162 |
+
async def create_connection(
|
| 163 |
+
self,
|
| 164 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 165 |
+
host: None = ...,
|
| 166 |
+
port: None = ...,
|
| 167 |
+
*,
|
| 168 |
+
ssl: _SSLContext = ...,
|
| 169 |
+
family: int = ...,
|
| 170 |
+
proto: int = ...,
|
| 171 |
+
flags: int = ...,
|
| 172 |
+
sock: socket,
|
| 173 |
+
local_addr: None = ...,
|
| 174 |
+
server_hostname: Optional[str] = ...,
|
| 175 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 176 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 177 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 178 |
+
async def create_unix_server(
|
| 179 |
+
self,
|
| 180 |
+
protocol_factory: asyncio.events._ProtocolFactory,
|
| 181 |
+
path: Optional[str] = ...,
|
| 182 |
+
*,
|
| 183 |
+
backlog: int = ...,
|
| 184 |
+
sock: Optional[socket] = ...,
|
| 185 |
+
ssl: _SSLContext = ...,
|
| 186 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 187 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 188 |
+
start_serving: bool = ...,
|
| 189 |
+
) -> asyncio.AbstractServer: ...
|
| 190 |
+
async def create_unix_connection(
|
| 191 |
+
self,
|
| 192 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 193 |
+
path: Optional[str] = ...,
|
| 194 |
+
*,
|
| 195 |
+
ssl: _SSLContext = ...,
|
| 196 |
+
sock: Optional[socket] = ...,
|
| 197 |
+
server_hostname: Optional[str] = ...,
|
| 198 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 199 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 200 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 201 |
+
def default_exception_handler(self, context: _Context) -> None: ...
|
| 202 |
+
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
|
| 203 |
+
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
|
| 204 |
+
def call_exception_handler(self, context: _Context) -> None: ...
|
| 205 |
+
def add_reader(self, fd: Any, callback: Callable[..., Any], *args: Any) -> None: ...
|
| 206 |
+
def remove_reader(self, fd: Any) -> None: ...
|
| 207 |
+
def add_writer(self, fd: Any, callback: Callable[..., Any], *args: Any) -> None: ...
|
| 208 |
+
def remove_writer(self, fd: Any) -> None: ...
|
| 209 |
+
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
| 210 |
+
async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ...
|
| 211 |
+
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
|
| 212 |
+
async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ...
|
| 213 |
+
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
|
| 214 |
+
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
|
| 215 |
+
async def sock_recvfrom_into(self, sock: socket, buf: bytearray, nbytes: int = ...) -> int: ...
|
| 216 |
+
async def sock_sendto(self, sock: socket, data: bytes, address: _Address) -> None: ...
|
| 217 |
+
async def connect_accepted_socket(
|
| 218 |
+
self,
|
| 219 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 220 |
+
sock: socket,
|
| 221 |
+
*,
|
| 222 |
+
ssl: _SSLContext = ...,
|
| 223 |
+
ssl_handshake_timeout: Optional[float] = ...,
|
| 224 |
+
ssl_shutdown_timeout: Optional[float] = ...,
|
| 225 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 226 |
+
async def run_in_executor(
|
| 227 |
+
self, executor: Any, func: Callable[..., _T], *args: Any
|
| 228 |
+
) -> _T: ...
|
| 229 |
+
def set_default_executor(self, executor: Any) -> None: ...
|
| 230 |
+
async def subprocess_shell(
|
| 231 |
+
self,
|
| 232 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 233 |
+
cmd: Union[bytes, str],
|
| 234 |
+
*,
|
| 235 |
+
stdin: Any = ...,
|
| 236 |
+
stdout: Any = ...,
|
| 237 |
+
stderr: Any = ...,
|
| 238 |
+
**kwargs: Any,
|
| 239 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 240 |
+
async def subprocess_exec(
|
| 241 |
+
self,
|
| 242 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 243 |
+
*args: Any,
|
| 244 |
+
stdin: Any = ...,
|
| 245 |
+
stdout: Any = ...,
|
| 246 |
+
stderr: Any = ...,
|
| 247 |
+
**kwargs: Any,
|
| 248 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 249 |
+
async def connect_read_pipe(
|
| 250 |
+
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
| 251 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 252 |
+
async def connect_write_pipe(
|
| 253 |
+
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
| 254 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 255 |
+
def add_signal_handler(
|
| 256 |
+
self, sig: int, callback: Callable[..., Any], *args: Any
|
| 257 |
+
) -> None: ...
|
| 258 |
+
def remove_signal_handler(self, sig: int) -> bool: ...
|
| 259 |
+
async def create_datagram_endpoint(
|
| 260 |
+
self,
|
| 261 |
+
protocol_factory: Callable[[], _ProtocolT],
|
| 262 |
+
local_addr: Optional[Tuple[str, int]] = ...,
|
| 263 |
+
remote_addr: Optional[Tuple[str, int]] = ...,
|
| 264 |
+
*,
|
| 265 |
+
family: int = ...,
|
| 266 |
+
proto: int = ...,
|
| 267 |
+
flags: int = ...,
|
| 268 |
+
reuse_address: Optional[bool] = ...,
|
| 269 |
+
reuse_port: Optional[bool] = ...,
|
| 270 |
+
allow_broadcast: Optional[bool] = ...,
|
| 271 |
+
sock: Optional[socket] = ...,
|
| 272 |
+
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
|
| 273 |
+
async def shutdown_asyncgens(self) -> None: ...
|
| 274 |
+
async def shutdown_default_executor(
|
| 275 |
+
self,
|
| 276 |
+
timeout: Optional[float] = ...,
|
| 277 |
+
) -> None: ...
|
| 278 |
+
# Loop doesn't implement these, but since they are marked as abstract in typeshed,
|
| 279 |
+
# we have to put them in so mypy thinks the base methods are overridden
|
| 280 |
+
async def sendfile(
|
| 281 |
+
self,
|
| 282 |
+
transport: asyncio.BaseTransport,
|
| 283 |
+
file: IO[bytes],
|
| 284 |
+
offset: int = ...,
|
| 285 |
+
count: Optional[int] = ...,
|
| 286 |
+
*,
|
| 287 |
+
fallback: bool = ...,
|
| 288 |
+
) -> int: ...
|
| 289 |
+
async def sock_sendfile(
|
| 290 |
+
self,
|
| 291 |
+
sock: socket,
|
| 292 |
+
file: IO[bytes],
|
| 293 |
+
offset: int = ...,
|
| 294 |
+
count: Optional[int] = ...,
|
| 295 |
+
*,
|
| 296 |
+
fallback: bool = ...
|
| 297 |
+
) -> int: ...
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/loop.pyx
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/lru.pyx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef object _LRU_MARKER = object()
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
@cython.final
|
| 5 |
+
cdef class LruCache:
|
| 6 |
+
|
| 7 |
+
cdef:
|
| 8 |
+
object _dict
|
| 9 |
+
int _maxsize
|
| 10 |
+
object _dict_move_to_end
|
| 11 |
+
object _dict_get
|
| 12 |
+
|
| 13 |
+
# We use an OrderedDict for LRU implementation. Operations:
|
| 14 |
+
#
|
| 15 |
+
# * We use a simple `__setitem__` to push a new entry:
|
| 16 |
+
# `entries[key] = new_entry`
|
| 17 |
+
# That will push `new_entry` to the *end* of the entries dict.
|
| 18 |
+
#
|
| 19 |
+
# * When we have a cache hit, we call
|
| 20 |
+
# `entries.move_to_end(key, last=True)`
|
| 21 |
+
# to move the entry to the *end* of the entries dict.
|
| 22 |
+
#
|
| 23 |
+
# * When we need to remove entries to maintain `max_size`, we call
|
| 24 |
+
# `entries.popitem(last=False)`
|
| 25 |
+
# to remove an entry from the *beginning* of the entries dict.
|
| 26 |
+
#
|
| 27 |
+
# So new entries and hits are always promoted to the end of the
|
| 28 |
+
# entries dict, whereas the unused one will group in the
|
| 29 |
+
# beginning of it.
|
| 30 |
+
|
| 31 |
+
def __init__(self, *, maxsize):
|
| 32 |
+
if maxsize <= 0:
|
| 33 |
+
raise ValueError(
|
| 34 |
+
f'maxsize is expected to be greater than 0, got {maxsize}')
|
| 35 |
+
|
| 36 |
+
self._dict = col_OrderedDict()
|
| 37 |
+
self._dict_move_to_end = self._dict.move_to_end
|
| 38 |
+
self._dict_get = self._dict.get
|
| 39 |
+
self._maxsize = maxsize
|
| 40 |
+
|
| 41 |
+
cdef get(self, key, default):
|
| 42 |
+
o = self._dict_get(key, _LRU_MARKER)
|
| 43 |
+
if o is _LRU_MARKER:
|
| 44 |
+
return default
|
| 45 |
+
self._dict_move_to_end(key) # last=True
|
| 46 |
+
return o
|
| 47 |
+
|
| 48 |
+
cdef inline needs_cleanup(self):
|
| 49 |
+
return len(self._dict) > self._maxsize
|
| 50 |
+
|
| 51 |
+
cdef inline cleanup_one(self):
|
| 52 |
+
k, _ = self._dict.popitem(last=False)
|
| 53 |
+
return k
|
| 54 |
+
|
| 55 |
+
def __getitem__(self, key):
|
| 56 |
+
o = self._dict[key]
|
| 57 |
+
self._dict_move_to_end(key) # last=True
|
| 58 |
+
return o
|
| 59 |
+
|
| 60 |
+
def __setitem__(self, key, o):
|
| 61 |
+
if key in self._dict:
|
| 62 |
+
self._dict[key] = o
|
| 63 |
+
self._dict_move_to_end(key) # last=True
|
| 64 |
+
else:
|
| 65 |
+
self._dict[key] = o
|
| 66 |
+
while self.needs_cleanup():
|
| 67 |
+
self.cleanup_one()
|
| 68 |
+
|
| 69 |
+
def __delitem__(self, key):
|
| 70 |
+
del self._dict[key]
|
| 71 |
+
|
| 72 |
+
def __contains__(self, key):
|
| 73 |
+
return key in self._dict
|
| 74 |
+
|
| 75 |
+
def __len__(self):
|
| 76 |
+
return len(self._dict)
|
| 77 |
+
|
| 78 |
+
def __iter__(self):
|
| 79 |
+
return iter(self._dict)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/pseudosock.pyx
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class PseudoSocket:
|
| 2 |
+
cdef:
|
| 3 |
+
int _family
|
| 4 |
+
int _type
|
| 5 |
+
int _proto
|
| 6 |
+
int _fd
|
| 7 |
+
object _peername
|
| 8 |
+
object _sockname
|
| 9 |
+
|
| 10 |
+
def __init__(self, int family, int type, int proto, int fd):
|
| 11 |
+
self._family = family
|
| 12 |
+
self._type = type
|
| 13 |
+
self._proto = proto
|
| 14 |
+
self._fd = fd
|
| 15 |
+
self._peername = None
|
| 16 |
+
self._sockname = None
|
| 17 |
+
|
| 18 |
+
cdef _na(self, what):
|
| 19 |
+
raise TypeError('transport sockets do not support {}'.format(what))
|
| 20 |
+
|
| 21 |
+
cdef _make_sock(self):
|
| 22 |
+
return socket_socket(self._family, self._type, self._proto, self._fd)
|
| 23 |
+
|
| 24 |
+
property family:
|
| 25 |
+
def __get__(self):
|
| 26 |
+
try:
|
| 27 |
+
return socket_AddressFamily(self._family)
|
| 28 |
+
except ValueError:
|
| 29 |
+
return self._family
|
| 30 |
+
|
| 31 |
+
property type:
|
| 32 |
+
def __get__(self):
|
| 33 |
+
try:
|
| 34 |
+
return socket_SocketKind(self._type)
|
| 35 |
+
except ValueError:
|
| 36 |
+
return self._type
|
| 37 |
+
|
| 38 |
+
property proto:
|
| 39 |
+
def __get__(self):
|
| 40 |
+
return self._proto
|
| 41 |
+
|
| 42 |
+
def __repr__(self):
|
| 43 |
+
s = ("<uvloop.PseudoSocket fd={}, family={!s}, "
|
| 44 |
+
"type={!s}, proto={}").format(self.fileno(), self.family.name,
|
| 45 |
+
self.type.name, self.proto)
|
| 46 |
+
|
| 47 |
+
if self._fd != -1:
|
| 48 |
+
try:
|
| 49 |
+
laddr = self.getsockname()
|
| 50 |
+
if laddr:
|
| 51 |
+
s += ", laddr=%s" % str(laddr)
|
| 52 |
+
except socket_error:
|
| 53 |
+
pass
|
| 54 |
+
try:
|
| 55 |
+
raddr = self.getpeername()
|
| 56 |
+
if raddr:
|
| 57 |
+
s += ", raddr=%s" % str(raddr)
|
| 58 |
+
except socket_error:
|
| 59 |
+
pass
|
| 60 |
+
s += '>'
|
| 61 |
+
return s
|
| 62 |
+
|
| 63 |
+
def __getstate__(self):
|
| 64 |
+
raise TypeError("Cannot serialize socket object")
|
| 65 |
+
|
| 66 |
+
def fileno(self):
|
| 67 |
+
return self._fd
|
| 68 |
+
|
| 69 |
+
def dup(self):
|
| 70 |
+
fd = os_dup(self._fd)
|
| 71 |
+
sock = socket_socket(self._family, self._type, self._proto, fileno=fd)
|
| 72 |
+
sock.settimeout(0)
|
| 73 |
+
return sock
|
| 74 |
+
|
| 75 |
+
def get_inheritable(self):
|
| 76 |
+
return os_get_inheritable(self._fd)
|
| 77 |
+
|
| 78 |
+
def set_inheritable(self):
|
| 79 |
+
os_set_inheritable(self._fd)
|
| 80 |
+
|
| 81 |
+
def ioctl(self, *args, **kwargs):
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
def getsockopt(self, *args, **kwargs):
|
| 85 |
+
sock = self._make_sock()
|
| 86 |
+
try:
|
| 87 |
+
return sock.getsockopt(*args, **kwargs)
|
| 88 |
+
finally:
|
| 89 |
+
sock.detach()
|
| 90 |
+
|
| 91 |
+
def setsockopt(self, *args, **kwargs):
|
| 92 |
+
sock = self._make_sock()
|
| 93 |
+
try:
|
| 94 |
+
return sock.setsockopt(*args, **kwargs)
|
| 95 |
+
finally:
|
| 96 |
+
sock.detach()
|
| 97 |
+
|
| 98 |
+
def getpeername(self):
|
| 99 |
+
if self._peername is not None:
|
| 100 |
+
return self._peername
|
| 101 |
+
|
| 102 |
+
sock = self._make_sock()
|
| 103 |
+
try:
|
| 104 |
+
self._peername = sock.getpeername()
|
| 105 |
+
return self._peername
|
| 106 |
+
finally:
|
| 107 |
+
sock.detach()
|
| 108 |
+
|
| 109 |
+
def getsockname(self):
|
| 110 |
+
if self._sockname is not None:
|
| 111 |
+
return self._sockname
|
| 112 |
+
|
| 113 |
+
sock = self._make_sock()
|
| 114 |
+
try:
|
| 115 |
+
self._sockname = sock.getsockname()
|
| 116 |
+
return self._sockname
|
| 117 |
+
finally:
|
| 118 |
+
sock.detach()
|
| 119 |
+
|
| 120 |
+
def share(self, process_id):
|
| 121 |
+
sock = self._make_sock()
|
| 122 |
+
try:
|
| 123 |
+
return sock.share(process_id)
|
| 124 |
+
finally:
|
| 125 |
+
sock.detach()
|
| 126 |
+
|
| 127 |
+
def accept(self):
|
| 128 |
+
self._na('accept() method')
|
| 129 |
+
|
| 130 |
+
def connect(self, *args):
|
| 131 |
+
self._na('connect() method')
|
| 132 |
+
|
| 133 |
+
def connect_ex(self, *args):
|
| 134 |
+
self._na('connect_ex() method')
|
| 135 |
+
|
| 136 |
+
def bind(self, *args):
|
| 137 |
+
self._na('bind() method')
|
| 138 |
+
|
| 139 |
+
def listen(self, *args, **kwargs):
|
| 140 |
+
self._na('listen() method')
|
| 141 |
+
|
| 142 |
+
def makefile(self):
|
| 143 |
+
self._na('makefile() method')
|
| 144 |
+
|
| 145 |
+
def sendfile(self, *args, **kwargs):
|
| 146 |
+
self._na('sendfile() method')
|
| 147 |
+
|
| 148 |
+
def close(self):
|
| 149 |
+
self._na('close() method')
|
| 150 |
+
|
| 151 |
+
def detach(self):
|
| 152 |
+
self._na('detach() method')
|
| 153 |
+
|
| 154 |
+
def shutdown(self, *args):
|
| 155 |
+
self._na('shutdown() method')
|
| 156 |
+
|
| 157 |
+
def sendmsg_afalg(self, *args, **kwargs):
|
| 158 |
+
self._na('sendmsg_afalg() method')
|
| 159 |
+
|
| 160 |
+
def sendmsg(self):
|
| 161 |
+
self._na('sendmsg() method')
|
| 162 |
+
|
| 163 |
+
def sendto(self, *args, **kwargs):
|
| 164 |
+
self._na('sendto() method')
|
| 165 |
+
|
| 166 |
+
def send(self, *args, **kwargs):
|
| 167 |
+
self._na('send() method')
|
| 168 |
+
|
| 169 |
+
def sendall(self, *args, **kwargs):
|
| 170 |
+
self._na('sendall() method')
|
| 171 |
+
|
| 172 |
+
def recv_into(self, *args, **kwargs):
|
| 173 |
+
self._na('recv_into() method')
|
| 174 |
+
|
| 175 |
+
def recvfrom_into(self, *args, **kwargs):
|
| 176 |
+
self._na('recvfrom_into() method')
|
| 177 |
+
|
| 178 |
+
def recvmsg_into(self, *args, **kwargs):
|
| 179 |
+
self._na('recvmsg_into() method')
|
| 180 |
+
|
| 181 |
+
def recvmsg(self, *args, **kwargs):
|
| 182 |
+
self._na('recvmsg() method')
|
| 183 |
+
|
| 184 |
+
def recvfrom(self, *args, **kwargs):
|
| 185 |
+
self._na('recvfrom() method')
|
| 186 |
+
|
| 187 |
+
def recv(self, *args, **kwargs):
|
| 188 |
+
self._na('recv() method')
|
| 189 |
+
|
| 190 |
+
def settimeout(self, value):
|
| 191 |
+
if value == 0:
|
| 192 |
+
return
|
| 193 |
+
raise ValueError(
|
| 194 |
+
'settimeout(): only 0 timeout is allowed on transport sockets')
|
| 195 |
+
|
| 196 |
+
def gettimeout(self):
|
| 197 |
+
return 0
|
| 198 |
+
|
| 199 |
+
def setblocking(self, flag):
|
| 200 |
+
if not flag:
|
| 201 |
+
return
|
| 202 |
+
raise ValueError(
|
| 203 |
+
'setblocking(): transport sockets cannot be blocking')
|
| 204 |
+
|
| 205 |
+
def __enter__(self):
|
| 206 |
+
self._na('context manager protocol')
|
| 207 |
+
|
| 208 |
+
def __exit__(self, *err):
|
| 209 |
+
self._na('context manager protocol')
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/py.typed
ADDED
|
File without changes
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/request.pxd
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVRequest:
|
| 2 |
+
cdef:
|
| 3 |
+
uv.uv_req_t *request
|
| 4 |
+
bint done
|
| 5 |
+
Loop loop
|
| 6 |
+
|
| 7 |
+
cdef on_done(self)
|
| 8 |
+
cdef cancel(self)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/request.pyx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class UVRequest:
|
| 2 |
+
"""A base class for all libuv requests (uv_getaddrinfo_t, etc).
|
| 3 |
+
|
| 4 |
+
Important: it's a responsibility of the subclass to call the
|
| 5 |
+
"on_done" method in the request's callback.
|
| 6 |
+
|
| 7 |
+
If "on_done" isn't called, the request object will never die.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
def __cinit__(self, Loop loop, *_):
|
| 11 |
+
self.request = NULL
|
| 12 |
+
self.loop = loop
|
| 13 |
+
self.done = 0
|
| 14 |
+
Py_INCREF(self)
|
| 15 |
+
|
| 16 |
+
cdef on_done(self):
|
| 17 |
+
self.done = 1
|
| 18 |
+
Py_DECREF(self)
|
| 19 |
+
|
| 20 |
+
cdef cancel(self):
|
| 21 |
+
# Most requests are implemented using a threadpool. It's only
|
| 22 |
+
# possible to cancel a request when it's still in a threadpool's
|
| 23 |
+
# queue. Once it's started to execute, we have to wait until
|
| 24 |
+
# it finishes and calls its callback (and callback *must* call
|
| 25 |
+
# UVRequest.on_done).
|
| 26 |
+
|
| 27 |
+
cdef int err
|
| 28 |
+
|
| 29 |
+
if self.done == 1:
|
| 30 |
+
return
|
| 31 |
+
|
| 32 |
+
if UVLOOP_DEBUG:
|
| 33 |
+
if self.request is NULL:
|
| 34 |
+
raise RuntimeError(
|
| 35 |
+
'{}.cancel: .request is NULL'.format(
|
| 36 |
+
self.__class__.__name__))
|
| 37 |
+
|
| 38 |
+
if self.request.data is NULL:
|
| 39 |
+
raise RuntimeError(
|
| 40 |
+
'{}.cancel: .request.data is NULL'.format(
|
| 41 |
+
self.__class__.__name__))
|
| 42 |
+
|
| 43 |
+
if <UVRequest>self.request.data is not self:
|
| 44 |
+
raise RuntimeError(
|
| 45 |
+
'{}.cancel: .request.data is not UVRequest'.format(
|
| 46 |
+
self.__class__.__name__))
|
| 47 |
+
|
| 48 |
+
# We only can cancel pending requests. Let's try.
|
| 49 |
+
err = uv.uv_cancel(self.request)
|
| 50 |
+
if err < 0:
|
| 51 |
+
if err == uv.UV_EBUSY:
|
| 52 |
+
# Can't close the request -- it's executing (see the first
|
| 53 |
+
# comment). Loop will have to wait until the callback
|
| 54 |
+
# fires.
|
| 55 |
+
pass
|
| 56 |
+
elif err == uv.UV_EINVAL:
|
| 57 |
+
# From libuv docs:
|
| 58 |
+
#
|
| 59 |
+
# Only cancellation of uv_fs_t, uv_getaddrinfo_t,
|
| 60 |
+
# uv_getnameinfo_t and uv_work_t requests is currently
|
| 61 |
+
# supported.
|
| 62 |
+
return
|
| 63 |
+
else:
|
| 64 |
+
ex = convert_error(err)
|
| 65 |
+
self.loop._handle_exception(ex)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/server.pxd
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef class Server:
|
| 2 |
+
cdef:
|
| 3 |
+
list _servers
|
| 4 |
+
list _waiters
|
| 5 |
+
int _active_count
|
| 6 |
+
Loop _loop
|
| 7 |
+
bint _serving
|
| 8 |
+
object _serving_forever_fut
|
| 9 |
+
object __weakref__
|
| 10 |
+
|
| 11 |
+
cdef _add_server(self, UVStreamServer srv)
|
| 12 |
+
cdef _start_serving(self)
|
| 13 |
+
cdef _wakeup(self)
|
| 14 |
+
|
| 15 |
+
cdef _attach(self)
|
| 16 |
+
cdef _detach(self)
|
| 17 |
+
|
| 18 |
+
cdef _ref(self)
|
| 19 |
+
cdef _unref(self)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/server.pyx
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
cdef class Server:
|
| 5 |
+
def __cinit__(self, Loop loop):
|
| 6 |
+
self._loop = loop
|
| 7 |
+
self._servers = []
|
| 8 |
+
self._waiters = []
|
| 9 |
+
self._active_count = 0
|
| 10 |
+
self._serving_forever_fut = None
|
| 11 |
+
|
| 12 |
+
cdef _add_server(self, UVStreamServer srv):
|
| 13 |
+
self._servers.append(srv)
|
| 14 |
+
|
| 15 |
+
cdef _start_serving(self):
|
| 16 |
+
if self._serving:
|
| 17 |
+
return
|
| 18 |
+
|
| 19 |
+
self._serving = 1
|
| 20 |
+
for server in self._servers:
|
| 21 |
+
(<UVStreamServer>server).listen()
|
| 22 |
+
|
| 23 |
+
cdef _wakeup(self):
|
| 24 |
+
cdef list waiters
|
| 25 |
+
|
| 26 |
+
waiters = self._waiters
|
| 27 |
+
self._waiters = None
|
| 28 |
+
for waiter in waiters:
|
| 29 |
+
if not waiter.done():
|
| 30 |
+
waiter.set_result(waiter)
|
| 31 |
+
|
| 32 |
+
cdef _attach(self):
|
| 33 |
+
assert self._servers is not None
|
| 34 |
+
self._active_count += 1
|
| 35 |
+
|
| 36 |
+
cdef _detach(self):
|
| 37 |
+
assert self._active_count > 0
|
| 38 |
+
self._active_count -= 1
|
| 39 |
+
if self._active_count == 0 and self._servers is None:
|
| 40 |
+
self._wakeup()
|
| 41 |
+
|
| 42 |
+
cdef _ref(self):
|
| 43 |
+
# Keep the server object alive while it's not explicitly closed.
|
| 44 |
+
self._loop._servers.add(self)
|
| 45 |
+
|
| 46 |
+
cdef _unref(self):
|
| 47 |
+
self._loop._servers.discard(self)
|
| 48 |
+
|
| 49 |
+
# Public API
|
| 50 |
+
|
| 51 |
+
@cython.iterable_coroutine
|
| 52 |
+
async def __aenter__(self):
|
| 53 |
+
return self
|
| 54 |
+
|
| 55 |
+
@cython.iterable_coroutine
|
| 56 |
+
async def __aexit__(self, *exc):
|
| 57 |
+
self.close()
|
| 58 |
+
await self.wait_closed()
|
| 59 |
+
|
| 60 |
+
def __repr__(self):
|
| 61 |
+
return '<%s sockets=%r>' % (self.__class__.__name__, self.sockets)
|
| 62 |
+
|
| 63 |
+
def get_loop(self):
|
| 64 |
+
return self._loop
|
| 65 |
+
|
| 66 |
+
@cython.iterable_coroutine
|
| 67 |
+
async def wait_closed(self):
|
| 68 |
+
# Do not remove `self._servers is None` below
|
| 69 |
+
# because close() method only closes server sockets
|
| 70 |
+
# and existing client connections are left open.
|
| 71 |
+
if self._servers is None or self._waiters is None:
|
| 72 |
+
return
|
| 73 |
+
waiter = self._loop._new_future()
|
| 74 |
+
self._waiters.append(waiter)
|
| 75 |
+
await waiter
|
| 76 |
+
|
| 77 |
+
def close(self):
|
| 78 |
+
cdef list servers
|
| 79 |
+
|
| 80 |
+
if self._servers is None:
|
| 81 |
+
return
|
| 82 |
+
|
| 83 |
+
try:
|
| 84 |
+
servers = self._servers
|
| 85 |
+
self._servers = None
|
| 86 |
+
self._serving = 0
|
| 87 |
+
|
| 88 |
+
for server in servers:
|
| 89 |
+
(<UVStreamServer>server)._close()
|
| 90 |
+
|
| 91 |
+
if self._active_count == 0:
|
| 92 |
+
self._wakeup()
|
| 93 |
+
finally:
|
| 94 |
+
self._unref()
|
| 95 |
+
|
| 96 |
+
def is_serving(self):
|
| 97 |
+
return self._serving
|
| 98 |
+
|
| 99 |
+
@cython.iterable_coroutine
|
| 100 |
+
async def start_serving(self):
|
| 101 |
+
self._start_serving()
|
| 102 |
+
|
| 103 |
+
@cython.iterable_coroutine
|
| 104 |
+
async def serve_forever(self):
|
| 105 |
+
if self._serving_forever_fut is not None:
|
| 106 |
+
raise RuntimeError(
|
| 107 |
+
f'server {self!r} is already being awaited on serve_forever()')
|
| 108 |
+
if self._servers is None:
|
| 109 |
+
raise RuntimeError(f'server {self!r} is closed')
|
| 110 |
+
|
| 111 |
+
self._start_serving()
|
| 112 |
+
self._serving_forever_fut = self._loop.create_future()
|
| 113 |
+
|
| 114 |
+
try:
|
| 115 |
+
await self._serving_forever_fut
|
| 116 |
+
except asyncio.CancelledError:
|
| 117 |
+
try:
|
| 118 |
+
self.close()
|
| 119 |
+
await self.wait_closed()
|
| 120 |
+
finally:
|
| 121 |
+
raise
|
| 122 |
+
finally:
|
| 123 |
+
self._serving_forever_fut = None
|
| 124 |
+
|
| 125 |
+
property sockets:
|
| 126 |
+
def __get__(self):
|
| 127 |
+
cdef list sockets = []
|
| 128 |
+
|
| 129 |
+
# Guard against `self._servers is None`
|
| 130 |
+
if self._servers:
|
| 131 |
+
for server in self._servers:
|
| 132 |
+
sockets.append(
|
| 133 |
+
(<UVStreamServer>server)._get_socket()
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
return sockets
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/sslproto.pxd
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef enum SSLProtocolState:
|
| 2 |
+
UNWRAPPED = 0
|
| 3 |
+
DO_HANDSHAKE = 1
|
| 4 |
+
WRAPPED = 2
|
| 5 |
+
FLUSHING = 3
|
| 6 |
+
SHUTDOWN = 4
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
cdef enum AppProtocolState:
|
| 10 |
+
# This tracks the state of app protocol (https://git.io/fj59P):
|
| 11 |
+
#
|
| 12 |
+
# INIT -cm-> CON_MADE [-dr*->] [-er-> EOF?] -cl-> CON_LOST
|
| 13 |
+
#
|
| 14 |
+
# * cm: connection_made()
|
| 15 |
+
# * dr: data_received()
|
| 16 |
+
# * er: eof_received()
|
| 17 |
+
# * cl: connection_lost()
|
| 18 |
+
|
| 19 |
+
STATE_INIT = 0
|
| 20 |
+
STATE_CON_MADE = 1
|
| 21 |
+
STATE_EOF = 2
|
| 22 |
+
STATE_CON_LOST = 3
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
cdef class _SSLProtocolTransport:
|
| 26 |
+
cdef:
|
| 27 |
+
Loop _loop
|
| 28 |
+
SSLProtocol _ssl_protocol
|
| 29 |
+
bint _closed
|
| 30 |
+
object context
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
cdef class SSLProtocol:
|
| 34 |
+
cdef:
|
| 35 |
+
bint _server_side
|
| 36 |
+
str _server_hostname
|
| 37 |
+
object _sslcontext
|
| 38 |
+
|
| 39 |
+
object _extra
|
| 40 |
+
|
| 41 |
+
object _write_backlog
|
| 42 |
+
size_t _write_buffer_size
|
| 43 |
+
|
| 44 |
+
object _waiter
|
| 45 |
+
Loop _loop
|
| 46 |
+
_SSLProtocolTransport _app_transport
|
| 47 |
+
bint _app_transport_created
|
| 48 |
+
|
| 49 |
+
object _transport
|
| 50 |
+
object _ssl_handshake_timeout
|
| 51 |
+
object _ssl_shutdown_timeout
|
| 52 |
+
|
| 53 |
+
object _sslobj
|
| 54 |
+
object _sslobj_read
|
| 55 |
+
object _sslobj_write
|
| 56 |
+
object _incoming
|
| 57 |
+
object _incoming_write
|
| 58 |
+
object _outgoing
|
| 59 |
+
object _outgoing_read
|
| 60 |
+
char* _ssl_buffer
|
| 61 |
+
size_t _ssl_buffer_len
|
| 62 |
+
object _ssl_buffer_view
|
| 63 |
+
SSLProtocolState _state
|
| 64 |
+
size_t _conn_lost
|
| 65 |
+
AppProtocolState _app_state
|
| 66 |
+
|
| 67 |
+
bint _ssl_writing_paused
|
| 68 |
+
bint _app_reading_paused
|
| 69 |
+
|
| 70 |
+
size_t _incoming_high_water
|
| 71 |
+
size_t _incoming_low_water
|
| 72 |
+
bint _ssl_reading_paused
|
| 73 |
+
|
| 74 |
+
bint _app_writing_paused
|
| 75 |
+
size_t _outgoing_high_water
|
| 76 |
+
size_t _outgoing_low_water
|
| 77 |
+
|
| 78 |
+
object _app_protocol
|
| 79 |
+
bint _app_protocol_is_buffer
|
| 80 |
+
object _app_protocol_get_buffer
|
| 81 |
+
object _app_protocol_buffer_updated
|
| 82 |
+
|
| 83 |
+
object _handshake_start_time
|
| 84 |
+
object _handshake_timeout_handle
|
| 85 |
+
object _shutdown_timeout_handle
|
| 86 |
+
|
| 87 |
+
cdef _set_app_protocol(self, app_protocol)
|
| 88 |
+
cdef _wakeup_waiter(self, exc=*)
|
| 89 |
+
cdef _get_extra_info(self, name, default=*)
|
| 90 |
+
cdef _set_state(self, SSLProtocolState new_state)
|
| 91 |
+
|
| 92 |
+
# Handshake flow
|
| 93 |
+
|
| 94 |
+
cdef _start_handshake(self)
|
| 95 |
+
cdef _check_handshake_timeout(self)
|
| 96 |
+
cdef _do_handshake(self)
|
| 97 |
+
cdef _on_handshake_complete(self, handshake_exc)
|
| 98 |
+
|
| 99 |
+
# Shutdown flow
|
| 100 |
+
|
| 101 |
+
cdef _start_shutdown(self, object context=*)
|
| 102 |
+
cdef _check_shutdown_timeout(self)
|
| 103 |
+
cdef _do_read_into_void(self, object context)
|
| 104 |
+
cdef _do_flush(self, object context=*)
|
| 105 |
+
cdef _do_shutdown(self, object context=*)
|
| 106 |
+
cdef _on_shutdown_complete(self, shutdown_exc)
|
| 107 |
+
cdef _abort(self, exc)
|
| 108 |
+
|
| 109 |
+
# Outgoing flow
|
| 110 |
+
|
| 111 |
+
cdef _write_appdata(self, list_of_data, object context)
|
| 112 |
+
cdef _do_write(self)
|
| 113 |
+
cdef _process_outgoing(self)
|
| 114 |
+
|
| 115 |
+
# Incoming flow
|
| 116 |
+
|
| 117 |
+
cdef _do_read(self)
|
| 118 |
+
cdef _do_read__buffered(self)
|
| 119 |
+
cdef _do_read__copied(self)
|
| 120 |
+
cdef _call_eof_received(self, object context=*)
|
| 121 |
+
|
| 122 |
+
# Flow control for writes from APP socket
|
| 123 |
+
|
| 124 |
+
cdef _control_app_writing(self, object context=*)
|
| 125 |
+
cdef size_t _get_write_buffer_size(self)
|
| 126 |
+
cdef _set_write_buffer_limits(self, high=*, low=*)
|
| 127 |
+
|
| 128 |
+
# Flow control for reads to APP socket
|
| 129 |
+
|
| 130 |
+
cdef _pause_reading(self)
|
| 131 |
+
cdef _resume_reading(self, object context)
|
| 132 |
+
|
| 133 |
+
# Flow control for reads from SSL socket
|
| 134 |
+
|
| 135 |
+
cdef _control_ssl_reading(self)
|
| 136 |
+
cdef _set_read_buffer_limits(self, high=*, low=*)
|
| 137 |
+
cdef size_t _get_read_buffer_size(self)
|
| 138 |
+
cdef _fatal_error(self, exc, message=*)
|
personalPromptBoost/.venv/lib/python3.13/site-packages/uvloop/sslproto.pyx
ADDED
|
@@ -0,0 +1,950 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef _create_transport_context(server_side, server_hostname):
|
| 2 |
+
if server_side:
|
| 3 |
+
raise ValueError('Server side SSL needs a valid SSLContext')
|
| 4 |
+
|
| 5 |
+
# Client side may pass ssl=True to use a default
|
| 6 |
+
# context; in that case the sslcontext passed is None.
|
| 7 |
+
# The default is secure for client connections.
|
| 8 |
+
# Python 3.4+: use up-to-date strong settings.
|
| 9 |
+
sslcontext = ssl_create_default_context()
|
| 10 |
+
if not server_hostname:
|
| 11 |
+
sslcontext.check_hostname = False
|
| 12 |
+
return sslcontext
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
cdef class _SSLProtocolTransport:
|
| 16 |
+
|
| 17 |
+
# TODO:
|
| 18 |
+
# _sendfile_compatible = constants._SendfileMode.FALLBACK
|
| 19 |
+
|
| 20 |
+
def __cinit__(self, Loop loop, ssl_protocol, context):
|
| 21 |
+
self._loop = loop
|
| 22 |
+
# SSLProtocol instance
|
| 23 |
+
self._ssl_protocol = ssl_protocol
|
| 24 |
+
self._closed = False
|
| 25 |
+
if context is None:
|
| 26 |
+
context = Context_CopyCurrent()
|
| 27 |
+
self.context = context
|
| 28 |
+
|
| 29 |
+
def get_extra_info(self, name, default=None):
|
| 30 |
+
"""Get optional transport information."""
|
| 31 |
+
return self._ssl_protocol._get_extra_info(name, default)
|
| 32 |
+
|
| 33 |
+
def set_protocol(self, protocol):
|
| 34 |
+
self._ssl_protocol._set_app_protocol(protocol)
|
| 35 |
+
|
| 36 |
+
def get_protocol(self):
|
| 37 |
+
return self._ssl_protocol._app_protocol
|
| 38 |
+
|
| 39 |
+
def is_closing(self):
|
| 40 |
+
return self._closed
|
| 41 |
+
|
| 42 |
+
def close(self):
|
| 43 |
+
"""Close the transport.
|
| 44 |
+
|
| 45 |
+
Buffered data will be flushed asynchronously. No more data
|
| 46 |
+
will be received. After all buffered data is flushed, the
|
| 47 |
+
protocol's connection_lost() method will (eventually) called
|
| 48 |
+
with None as its argument.
|
| 49 |
+
"""
|
| 50 |
+
self._closed = True
|
| 51 |
+
self._ssl_protocol._start_shutdown(self.context.copy())
|
| 52 |
+
|
| 53 |
+
def __dealloc__(self):
|
| 54 |
+
if not self._closed:
|
| 55 |
+
self._closed = True
|
| 56 |
+
warnings_warn(
|
| 57 |
+
"unclosed transport <uvloop.loop._SSLProtocolTransport "
|
| 58 |
+
"object>", ResourceWarning)
|
| 59 |
+
|
| 60 |
+
def is_reading(self):
|
| 61 |
+
return not self._ssl_protocol._app_reading_paused
|
| 62 |
+
|
| 63 |
+
def pause_reading(self):
|
| 64 |
+
"""Pause the receiving end.
|
| 65 |
+
|
| 66 |
+
No data will be passed to the protocol's data_received()
|
| 67 |
+
method until resume_reading() is called.
|
| 68 |
+
"""
|
| 69 |
+
self._ssl_protocol._pause_reading()
|
| 70 |
+
|
| 71 |
+
def resume_reading(self):
|
| 72 |
+
"""Resume the receiving end.
|
| 73 |
+
|
| 74 |
+
Data received will once again be passed to the protocol's
|
| 75 |
+
data_received() method.
|
| 76 |
+
"""
|
| 77 |
+
self._ssl_protocol._resume_reading(self.context.copy())
|
| 78 |
+
|
| 79 |
+
def set_write_buffer_limits(self, high=None, low=None):
|
| 80 |
+
"""Set the high- and low-water limits for write flow control.
|
| 81 |
+
|
| 82 |
+
These two values control when to call the protocol's
|
| 83 |
+
pause_writing() and resume_writing() methods. If specified,
|
| 84 |
+
the low-water limit must be less than or equal to the
|
| 85 |
+
high-water limit. Neither value can be negative.
|
| 86 |
+
|
| 87 |
+
The defaults are implementation-specific. If only the
|
| 88 |
+
high-water limit is given, the low-water limit defaults to an
|
| 89 |
+
implementation-specific value less than or equal to the
|
| 90 |
+
high-water limit. Setting high to zero forces low to zero as
|
| 91 |
+
well, and causes pause_writing() to be called whenever the
|
| 92 |
+
buffer becomes non-empty. Setting low to zero causes
|
| 93 |
+
resume_writing() to be called only once the buffer is empty.
|
| 94 |
+
Use of zero for either limit is generally sub-optimal as it
|
| 95 |
+
reduces opportunities for doing I/O and computation
|
| 96 |
+
concurrently.
|
| 97 |
+
"""
|
| 98 |
+
self._ssl_protocol._set_write_buffer_limits(high, low)
|
| 99 |
+
self._ssl_protocol._control_app_writing(self.context.copy())
|
| 100 |
+
|
| 101 |
+
def get_write_buffer_limits(self):
|
| 102 |
+
return (self._ssl_protocol._outgoing_low_water,
|
| 103 |
+
self._ssl_protocol._outgoing_high_water)
|
| 104 |
+
|
| 105 |
+
def get_write_buffer_size(self):
|
| 106 |
+
"""Return the current size of the write buffers."""
|
| 107 |
+
return self._ssl_protocol._get_write_buffer_size()
|
| 108 |
+
|
| 109 |
+
def set_read_buffer_limits(self, high=None, low=None):
|
| 110 |
+
"""Set the high- and low-water limits for read flow control.
|
| 111 |
+
|
| 112 |
+
These two values control when to call the upstream transport's
|
| 113 |
+
pause_reading() and resume_reading() methods. If specified,
|
| 114 |
+
the low-water limit must be less than or equal to the
|
| 115 |
+
high-water limit. Neither value can be negative.
|
| 116 |
+
|
| 117 |
+
The defaults are implementation-specific. If only the
|
| 118 |
+
high-water limit is given, the low-water limit defaults to an
|
| 119 |
+
implementation-specific value less than or equal to the
|
| 120 |
+
high-water limit. Setting high to zero forces low to zero as
|
| 121 |
+
well, and causes pause_reading() to be called whenever the
|
| 122 |
+
buffer becomes non-empty. Setting low to zero causes
|
| 123 |
+
resume_reading() to be called only once the buffer is empty.
|
| 124 |
+
Use of zero for either limit is generally sub-optimal as it
|
| 125 |
+
reduces opportunities for doing I/O and computation
|
| 126 |
+
concurrently.
|
| 127 |
+
"""
|
| 128 |
+
self._ssl_protocol._set_read_buffer_limits(high, low)
|
| 129 |
+
self._ssl_protocol._control_ssl_reading()
|
| 130 |
+
|
| 131 |
+
def get_read_buffer_limits(self):
|
| 132 |
+
return (self._ssl_protocol._incoming_low_water,
|
| 133 |
+
self._ssl_protocol._incoming_high_water)
|
| 134 |
+
|
| 135 |
+
def get_read_buffer_size(self):
|
| 136 |
+
"""Return the current size of the read buffer."""
|
| 137 |
+
return self._ssl_protocol._get_read_buffer_size()
|
| 138 |
+
|
| 139 |
+
@property
|
| 140 |
+
def _protocol_paused(self):
|
| 141 |
+
# Required for sendfile fallback pause_writing/resume_writing logic
|
| 142 |
+
return self._ssl_protocol._app_writing_paused
|
| 143 |
+
|
| 144 |
+
def write(self, data):
|
| 145 |
+
"""Write some data bytes to the transport.
|
| 146 |
+
|
| 147 |
+
This does not block; it buffers the data and arranges for it
|
| 148 |
+
to be sent out asynchronously.
|
| 149 |
+
"""
|
| 150 |
+
if not isinstance(data, (bytes, bytearray, memoryview)):
|
| 151 |
+
raise TypeError(f"data: expecting a bytes-like instance, "
|
| 152 |
+
f"got {type(data).__name__}")
|
| 153 |
+
if not data:
|
| 154 |
+
return
|
| 155 |
+
self._ssl_protocol._write_appdata((data,), self.context.copy())
|
| 156 |
+
|
| 157 |
+
def writelines(self, list_of_data):
|
| 158 |
+
"""Write a list (or any iterable) of data bytes to the transport.
|
| 159 |
+
|
| 160 |
+
The default implementation concatenates the arguments and
|
| 161 |
+
calls write() on the result.
|
| 162 |
+
"""
|
| 163 |
+
self._ssl_protocol._write_appdata(list_of_data, self.context.copy())
|
| 164 |
+
|
| 165 |
+
def write_eof(self):
|
| 166 |
+
"""Close the write end after flushing buffered data.
|
| 167 |
+
|
| 168 |
+
This raises :exc:`NotImplementedError` right now.
|
| 169 |
+
"""
|
| 170 |
+
raise NotImplementedError
|
| 171 |
+
|
| 172 |
+
def can_write_eof(self):
|
| 173 |
+
"""Return True if this transport supports write_eof(), False if not."""
|
| 174 |
+
return False
|
| 175 |
+
|
| 176 |
+
def abort(self):
|
| 177 |
+
"""Close the transport immediately.
|
| 178 |
+
|
| 179 |
+
Buffered data will be lost. No more data will be received.
|
| 180 |
+
The protocol's connection_lost() method will (eventually) be
|
| 181 |
+
called with None as its argument.
|
| 182 |
+
"""
|
| 183 |
+
self._force_close(None)
|
| 184 |
+
|
| 185 |
+
def _force_close(self, exc):
|
| 186 |
+
self._closed = True
|
| 187 |
+
self._ssl_protocol._abort(exc)
|
| 188 |
+
|
| 189 |
+
def _test__append_write_backlog(self, data):
|
| 190 |
+
# for test only
|
| 191 |
+
self._ssl_protocol._write_backlog.append(data)
|
| 192 |
+
self._ssl_protocol._write_buffer_size += len(data)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
cdef class SSLProtocol:
|
| 196 |
+
"""SSL protocol.
|
| 197 |
+
|
| 198 |
+
Implementation of SSL on top of a socket using incoming and outgoing
|
| 199 |
+
buffers which are ssl.MemoryBIO objects.
|
| 200 |
+
"""
|
| 201 |
+
|
| 202 |
+
def __cinit__(self, *args, **kwargs):
|
| 203 |
+
self._ssl_buffer_len = SSL_READ_MAX_SIZE
|
| 204 |
+
self._ssl_buffer = <char*>PyMem_RawMalloc(self._ssl_buffer_len)
|
| 205 |
+
if not self._ssl_buffer:
|
| 206 |
+
raise MemoryError()
|
| 207 |
+
self._ssl_buffer_view = PyMemoryView_FromMemory(
|
| 208 |
+
self._ssl_buffer, self._ssl_buffer_len, PyBUF_WRITE)
|
| 209 |
+
|
| 210 |
+
def __dealloc__(self):
|
| 211 |
+
self._ssl_buffer_view = None
|
| 212 |
+
PyMem_RawFree(self._ssl_buffer)
|
| 213 |
+
self._ssl_buffer = NULL
|
| 214 |
+
self._ssl_buffer_len = 0
|
| 215 |
+
|
| 216 |
+
def __init__(self, loop, app_protocol, sslcontext, waiter,
|
| 217 |
+
server_side=False, server_hostname=None,
|
| 218 |
+
call_connection_made=True,
|
| 219 |
+
ssl_handshake_timeout=None,
|
| 220 |
+
ssl_shutdown_timeout=None):
|
| 221 |
+
if ssl_handshake_timeout is None:
|
| 222 |
+
ssl_handshake_timeout = SSL_HANDSHAKE_TIMEOUT
|
| 223 |
+
elif ssl_handshake_timeout <= 0:
|
| 224 |
+
raise ValueError(
|
| 225 |
+
f"ssl_handshake_timeout should be a positive number, "
|
| 226 |
+
f"got {ssl_handshake_timeout}")
|
| 227 |
+
if ssl_shutdown_timeout is None:
|
| 228 |
+
ssl_shutdown_timeout = SSL_SHUTDOWN_TIMEOUT
|
| 229 |
+
elif ssl_shutdown_timeout <= 0:
|
| 230 |
+
raise ValueError(
|
| 231 |
+
f"ssl_shutdown_timeout should be a positive number, "
|
| 232 |
+
f"got {ssl_shutdown_timeout}")
|
| 233 |
+
|
| 234 |
+
if not sslcontext:
|
| 235 |
+
sslcontext = _create_transport_context(
|
| 236 |
+
server_side, server_hostname)
|
| 237 |
+
|
| 238 |
+
self._server_side = server_side
|
| 239 |
+
if server_hostname and not server_side:
|
| 240 |
+
self._server_hostname = server_hostname
|
| 241 |
+
else:
|
| 242 |
+
self._server_hostname = None
|
| 243 |
+
self._sslcontext = sslcontext
|
| 244 |
+
# SSL-specific extra info. More info are set when the handshake
|
| 245 |
+
# completes.
|
| 246 |
+
self._extra = dict(sslcontext=sslcontext)
|
| 247 |
+
|
| 248 |
+
# App data write buffering
|
| 249 |
+
self._write_backlog = col_deque()
|
| 250 |
+
self._write_buffer_size = 0
|
| 251 |
+
|
| 252 |
+
self._waiter = waiter
|
| 253 |
+
self._loop = loop
|
| 254 |
+
self._set_app_protocol(app_protocol)
|
| 255 |
+
self._app_transport = None
|
| 256 |
+
self._app_transport_created = False
|
| 257 |
+
# transport, ex: SelectorSocketTransport
|
| 258 |
+
self._transport = None
|
| 259 |
+
self._ssl_handshake_timeout = ssl_handshake_timeout
|
| 260 |
+
self._ssl_shutdown_timeout = ssl_shutdown_timeout
|
| 261 |
+
# SSL and state machine
|
| 262 |
+
self._sslobj = None
|
| 263 |
+
self._incoming = ssl_MemoryBIO()
|
| 264 |
+
self._incoming_write = self._incoming.write
|
| 265 |
+
self._outgoing = ssl_MemoryBIO()
|
| 266 |
+
self._outgoing_read = self._outgoing.read
|
| 267 |
+
self._state = UNWRAPPED
|
| 268 |
+
self._conn_lost = 0 # Set when connection_lost called
|
| 269 |
+
if call_connection_made:
|
| 270 |
+
self._app_state = STATE_INIT
|
| 271 |
+
else:
|
| 272 |
+
self._app_state = STATE_CON_MADE
|
| 273 |
+
|
| 274 |
+
# Flow Control
|
| 275 |
+
|
| 276 |
+
self._ssl_writing_paused = False
|
| 277 |
+
|
| 278 |
+
self._app_reading_paused = False
|
| 279 |
+
|
| 280 |
+
self._ssl_reading_paused = False
|
| 281 |
+
self._incoming_high_water = 0
|
| 282 |
+
self._incoming_low_water = 0
|
| 283 |
+
self._set_read_buffer_limits()
|
| 284 |
+
|
| 285 |
+
self._app_writing_paused = False
|
| 286 |
+
self._outgoing_high_water = 0
|
| 287 |
+
self._outgoing_low_water = 0
|
| 288 |
+
self._set_write_buffer_limits()
|
| 289 |
+
|
| 290 |
+
cdef _set_app_protocol(self, app_protocol):
|
| 291 |
+
self._app_protocol = app_protocol
|
| 292 |
+
if (hasattr(app_protocol, 'get_buffer') and
|
| 293 |
+
not isinstance(app_protocol, aio_Protocol)):
|
| 294 |
+
self._app_protocol_get_buffer = app_protocol.get_buffer
|
| 295 |
+
self._app_protocol_buffer_updated = app_protocol.buffer_updated
|
| 296 |
+
self._app_protocol_is_buffer = True
|
| 297 |
+
else:
|
| 298 |
+
self._app_protocol_is_buffer = False
|
| 299 |
+
|
| 300 |
+
cdef _wakeup_waiter(self, exc=None):
|
| 301 |
+
if self._waiter is None:
|
| 302 |
+
return
|
| 303 |
+
if not self._waiter.cancelled():
|
| 304 |
+
if exc is not None:
|
| 305 |
+
self._waiter.set_exception(exc)
|
| 306 |
+
else:
|
| 307 |
+
self._waiter.set_result(None)
|
| 308 |
+
self._waiter = None
|
| 309 |
+
|
| 310 |
+
def _get_app_transport(self, context=None):
|
| 311 |
+
if self._app_transport is None:
|
| 312 |
+
if self._app_transport_created:
|
| 313 |
+
raise RuntimeError('Creating _SSLProtocolTransport twice')
|
| 314 |
+
self._app_transport = _SSLProtocolTransport(self._loop, self,
|
| 315 |
+
context)
|
| 316 |
+
self._app_transport_created = True
|
| 317 |
+
return self._app_transport
|
| 318 |
+
|
| 319 |
+
def connection_made(self, transport):
|
| 320 |
+
"""Called when the low-level connection is made.
|
| 321 |
+
|
| 322 |
+
Start the SSL handshake.
|
| 323 |
+
"""
|
| 324 |
+
self._transport = transport
|
| 325 |
+
self._start_handshake()
|
| 326 |
+
|
| 327 |
+
def connection_lost(self, exc):
|
| 328 |
+
"""Called when the low-level connection is lost or closed.
|
| 329 |
+
|
| 330 |
+
The argument is an exception object or None (the latter
|
| 331 |
+
meaning a regular EOF is received or the connection was
|
| 332 |
+
aborted or closed).
|
| 333 |
+
"""
|
| 334 |
+
self._write_backlog.clear()
|
| 335 |
+
self._outgoing_read()
|
| 336 |
+
self._conn_lost += 1
|
| 337 |
+
|
| 338 |
+
# Just mark the app transport as closed so that its __dealloc__
|
| 339 |
+
# doesn't complain.
|
| 340 |
+
if self._app_transport is not None:
|
| 341 |
+
self._app_transport._closed = True
|
| 342 |
+
|
| 343 |
+
if self._state != DO_HANDSHAKE:
|
| 344 |
+
if self._app_state == STATE_CON_MADE or \
|
| 345 |
+
self._app_state == STATE_EOF:
|
| 346 |
+
self._app_state = STATE_CON_LOST
|
| 347 |
+
self._loop.call_soon(self._app_protocol.connection_lost, exc)
|
| 348 |
+
self._set_state(UNWRAPPED)
|
| 349 |
+
self._transport = None
|
| 350 |
+
self._app_transport = None
|
| 351 |
+
self._app_protocol = None
|
| 352 |
+
self._wakeup_waiter(exc)
|
| 353 |
+
|
| 354 |
+
if self._shutdown_timeout_handle:
|
| 355 |
+
self._shutdown_timeout_handle.cancel()
|
| 356 |
+
self._shutdown_timeout_handle = None
|
| 357 |
+
if self._handshake_timeout_handle:
|
| 358 |
+
self._handshake_timeout_handle.cancel()
|
| 359 |
+
self._handshake_timeout_handle = None
|
| 360 |
+
|
| 361 |
+
def get_buffer(self, n):
|
| 362 |
+
cdef size_t want = n
|
| 363 |
+
if want > SSL_READ_MAX_SIZE:
|
| 364 |
+
want = SSL_READ_MAX_SIZE
|
| 365 |
+
if self._ssl_buffer_len < want:
|
| 366 |
+
self._ssl_buffer = <char*>PyMem_RawRealloc(self._ssl_buffer, want)
|
| 367 |
+
if not self._ssl_buffer:
|
| 368 |
+
raise MemoryError()
|
| 369 |
+
self._ssl_buffer_len = want
|
| 370 |
+
self._ssl_buffer_view = PyMemoryView_FromMemory(
|
| 371 |
+
self._ssl_buffer, want, PyBUF_WRITE)
|
| 372 |
+
return self._ssl_buffer_view
|
| 373 |
+
|
| 374 |
+
def buffer_updated(self, nbytes):
|
| 375 |
+
self._incoming_write(PyMemoryView_FromMemory(
|
| 376 |
+
self._ssl_buffer, nbytes, PyBUF_WRITE))
|
| 377 |
+
|
| 378 |
+
if self._state == DO_HANDSHAKE:
|
| 379 |
+
self._do_handshake()
|
| 380 |
+
|
| 381 |
+
elif self._state == WRAPPED:
|
| 382 |
+
self._do_read()
|
| 383 |
+
|
| 384 |
+
elif self._state == FLUSHING:
|
| 385 |
+
self._do_flush()
|
| 386 |
+
|
| 387 |
+
elif self._state == SHUTDOWN:
|
| 388 |
+
self._do_shutdown()
|
| 389 |
+
|
| 390 |
+
def eof_received(self):
|
| 391 |
+
"""Called when the other end of the low-level stream
|
| 392 |
+
is half-closed.
|
| 393 |
+
|
| 394 |
+
If this returns a false value (including None), the transport
|
| 395 |
+
will close itself. If it returns a true value, closing the
|
| 396 |
+
transport is up to the protocol.
|
| 397 |
+
"""
|
| 398 |
+
try:
|
| 399 |
+
if self._loop.get_debug():
|
| 400 |
+
aio_logger.debug("%r received EOF", self)
|
| 401 |
+
|
| 402 |
+
if self._state == DO_HANDSHAKE:
|
| 403 |
+
self._on_handshake_complete(ConnectionResetError)
|
| 404 |
+
|
| 405 |
+
elif self._state == WRAPPED or self._state == FLUSHING:
|
| 406 |
+
# We treat a low-level EOF as a critical situation similar to a
|
| 407 |
+
# broken connection - just send whatever is in the buffer and
|
| 408 |
+
# close. No application level eof_received() is called -
|
| 409 |
+
# because we don't want the user to think that this is a
|
| 410 |
+
# graceful shutdown triggered by SSL "close_notify".
|
| 411 |
+
self._set_state(SHUTDOWN)
|
| 412 |
+
self._on_shutdown_complete(None)
|
| 413 |
+
|
| 414 |
+
elif self._state == SHUTDOWN:
|
| 415 |
+
self._on_shutdown_complete(None)
|
| 416 |
+
|
| 417 |
+
except Exception:
|
| 418 |
+
self._transport.close()
|
| 419 |
+
raise
|
| 420 |
+
|
| 421 |
+
cdef _get_extra_info(self, name, default=None):
|
| 422 |
+
if name == 'uvloop.sslproto':
|
| 423 |
+
return self
|
| 424 |
+
elif name in self._extra:
|
| 425 |
+
return self._extra[name]
|
| 426 |
+
elif self._transport is not None:
|
| 427 |
+
return self._transport.get_extra_info(name, default)
|
| 428 |
+
else:
|
| 429 |
+
return default
|
| 430 |
+
|
| 431 |
+
cdef _set_state(self, SSLProtocolState new_state):
|
| 432 |
+
cdef bint allowed = False
|
| 433 |
+
|
| 434 |
+
if new_state == UNWRAPPED:
|
| 435 |
+
allowed = True
|
| 436 |
+
|
| 437 |
+
elif self._state == UNWRAPPED and new_state == DO_HANDSHAKE:
|
| 438 |
+
allowed = True
|
| 439 |
+
|
| 440 |
+
elif self._state == DO_HANDSHAKE and new_state == WRAPPED:
|
| 441 |
+
allowed = True
|
| 442 |
+
|
| 443 |
+
elif self._state == WRAPPED and new_state == FLUSHING:
|
| 444 |
+
allowed = True
|
| 445 |
+
|
| 446 |
+
elif self._state == WRAPPED and new_state == SHUTDOWN:
|
| 447 |
+
allowed = True
|
| 448 |
+
|
| 449 |
+
elif self._state == FLUSHING and new_state == SHUTDOWN:
|
| 450 |
+
allowed = True
|
| 451 |
+
|
| 452 |
+
if allowed:
|
| 453 |
+
self._state = new_state
|
| 454 |
+
|
| 455 |
+
else:
|
| 456 |
+
raise RuntimeError(
|
| 457 |
+
'cannot switch state from {} to {}'.format(
|
| 458 |
+
self._state, new_state))
|
| 459 |
+
|
| 460 |
+
# Handshake flow
|
| 461 |
+
|
| 462 |
+
cdef _start_handshake(self):
|
| 463 |
+
if self._loop.get_debug():
|
| 464 |
+
aio_logger.debug("%r starts SSL handshake", self)
|
| 465 |
+
self._handshake_start_time = self._loop.time()
|
| 466 |
+
else:
|
| 467 |
+
self._handshake_start_time = None
|
| 468 |
+
|
| 469 |
+
self._set_state(DO_HANDSHAKE)
|
| 470 |
+
|
| 471 |
+
# start handshake timeout count down
|
| 472 |
+
self._handshake_timeout_handle = \
|
| 473 |
+
self._loop.call_later(self._ssl_handshake_timeout,
|
| 474 |
+
lambda: self._check_handshake_timeout())
|
| 475 |
+
|
| 476 |
+
try:
|
| 477 |
+
self._sslobj = self._sslcontext.wrap_bio(
|
| 478 |
+
self._incoming, self._outgoing,
|
| 479 |
+
server_side=self._server_side,
|
| 480 |
+
server_hostname=self._server_hostname)
|
| 481 |
+
self._sslobj_read = self._sslobj.read
|
| 482 |
+
self._sslobj_write = self._sslobj.write
|
| 483 |
+
except Exception as ex:
|
| 484 |
+
self._on_handshake_complete(ex)
|
| 485 |
+
else:
|
| 486 |
+
self._do_handshake()
|
| 487 |
+
|
| 488 |
+
cdef _check_handshake_timeout(self):
|
| 489 |
+
if self._state == DO_HANDSHAKE:
|
| 490 |
+
msg = (
|
| 491 |
+
f"SSL handshake is taking longer than "
|
| 492 |
+
f"{self._ssl_handshake_timeout} seconds: "
|
| 493 |
+
f"aborting the connection"
|
| 494 |
+
)
|
| 495 |
+
self._fatal_error(ConnectionAbortedError(msg))
|
| 496 |
+
|
| 497 |
+
cdef _do_handshake(self):
|
| 498 |
+
try:
|
| 499 |
+
self._sslobj.do_handshake()
|
| 500 |
+
except ssl_SSLAgainErrors as exc:
|
| 501 |
+
self._process_outgoing()
|
| 502 |
+
except ssl_SSLError as exc:
|
| 503 |
+
self._on_handshake_complete(exc)
|
| 504 |
+
else:
|
| 505 |
+
self._on_handshake_complete(None)
|
| 506 |
+
|
| 507 |
+
cdef _on_handshake_complete(self, handshake_exc):
|
| 508 |
+
if self._handshake_timeout_handle is not None:
|
| 509 |
+
self._handshake_timeout_handle.cancel()
|
| 510 |
+
self._handshake_timeout_handle = None
|
| 511 |
+
|
| 512 |
+
sslobj = self._sslobj
|
| 513 |
+
try:
|
| 514 |
+
if handshake_exc is None:
|
| 515 |
+
self._set_state(WRAPPED)
|
| 516 |
+
else:
|
| 517 |
+
raise handshake_exc
|
| 518 |
+
|
| 519 |
+
peercert = sslobj.getpeercert()
|
| 520 |
+
except Exception as exc:
|
| 521 |
+
self._set_state(UNWRAPPED)
|
| 522 |
+
if isinstance(exc, ssl_CertificateError):
|
| 523 |
+
msg = 'SSL handshake failed on verifying the certificate'
|
| 524 |
+
else:
|
| 525 |
+
msg = 'SSL handshake failed'
|
| 526 |
+
self._fatal_error(exc, msg)
|
| 527 |
+
self._wakeup_waiter(exc)
|
| 528 |
+
return
|
| 529 |
+
|
| 530 |
+
if self._loop.get_debug():
|
| 531 |
+
dt = self._loop.time() - self._handshake_start_time
|
| 532 |
+
aio_logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3)
|
| 533 |
+
|
| 534 |
+
# Add extra info that becomes available after handshake.
|
| 535 |
+
self._extra.update(peercert=peercert,
|
| 536 |
+
cipher=sslobj.cipher(),
|
| 537 |
+
compression=sslobj.compression(),
|
| 538 |
+
ssl_object=sslobj)
|
| 539 |
+
if self._app_state == STATE_INIT:
|
| 540 |
+
self._app_state = STATE_CON_MADE
|
| 541 |
+
self._app_protocol.connection_made(self._get_app_transport())
|
| 542 |
+
self._wakeup_waiter()
|
| 543 |
+
|
| 544 |
+
# We should wakeup user code before sending the first data below. In
|
| 545 |
+
# case of `start_tls()`, the user can only get the SSLTransport in the
|
| 546 |
+
# wakeup callback, because `connection_made()` is not called again.
|
| 547 |
+
# We should schedule the first data later than the wakeup callback so
|
| 548 |
+
# that the user get a chance to e.g. check ALPN with the transport
|
| 549 |
+
# before having to handle the first data.
|
| 550 |
+
self._loop._call_soon_handle(
|
| 551 |
+
new_MethodHandle(self._loop,
|
| 552 |
+
"SSLProtocol._do_read",
|
| 553 |
+
<method_t> self._do_read,
|
| 554 |
+
None, # current context is good
|
| 555 |
+
self))
|
| 556 |
+
|
| 557 |
+
# Shutdown flow
|
| 558 |
+
|
| 559 |
+
cdef _start_shutdown(self, object context=None):
|
| 560 |
+
if self._state in (FLUSHING, SHUTDOWN, UNWRAPPED):
|
| 561 |
+
return
|
| 562 |
+
# we don't need the context for _abort or the timeout, because
|
| 563 |
+
# TCP transport._force_close() should be able to call
|
| 564 |
+
# connection_lost() in the right context
|
| 565 |
+
if self._app_transport is not None:
|
| 566 |
+
self._app_transport._closed = True
|
| 567 |
+
if self._state == DO_HANDSHAKE:
|
| 568 |
+
self._abort(None)
|
| 569 |
+
else:
|
| 570 |
+
self._set_state(FLUSHING)
|
| 571 |
+
self._shutdown_timeout_handle = \
|
| 572 |
+
self._loop.call_later(self._ssl_shutdown_timeout,
|
| 573 |
+
lambda: self._check_shutdown_timeout())
|
| 574 |
+
self._do_flush(context)
|
| 575 |
+
|
| 576 |
+
cdef _check_shutdown_timeout(self):
|
| 577 |
+
if self._state in (FLUSHING, SHUTDOWN):
|
| 578 |
+
self._transport._force_close(
|
| 579 |
+
aio_TimeoutError('SSL shutdown timed out'))
|
| 580 |
+
|
| 581 |
+
cdef _do_read_into_void(self, object context):
|
| 582 |
+
"""Consume and discard incoming application data.
|
| 583 |
+
|
| 584 |
+
If close_notify is received for the first time, call eof_received.
|
| 585 |
+
"""
|
| 586 |
+
cdef:
|
| 587 |
+
bint close_notify = False
|
| 588 |
+
try:
|
| 589 |
+
while True:
|
| 590 |
+
if not self._sslobj_read(SSL_READ_MAX_SIZE):
|
| 591 |
+
close_notify = True
|
| 592 |
+
break
|
| 593 |
+
except ssl_SSLAgainErrors as exc:
|
| 594 |
+
pass
|
| 595 |
+
except ssl_SSLZeroReturnError:
|
| 596 |
+
close_notify = True
|
| 597 |
+
if close_notify:
|
| 598 |
+
self._call_eof_received(context)
|
| 599 |
+
|
| 600 |
+
cdef _do_flush(self, object context=None):
|
| 601 |
+
"""Flush the write backlog, discarding new data received.
|
| 602 |
+
|
| 603 |
+
We don't send close_notify in FLUSHING because we still want to send
|
| 604 |
+
the remaining data over SSL, even if we received a close_notify. Also,
|
| 605 |
+
no application-level resume_writing() or pause_writing() will be called
|
| 606 |
+
in FLUSHING, as we could fully manage the flow control internally.
|
| 607 |
+
"""
|
| 608 |
+
try:
|
| 609 |
+
self._do_read_into_void(context)
|
| 610 |
+
self._do_write()
|
| 611 |
+
self._process_outgoing()
|
| 612 |
+
self._control_ssl_reading()
|
| 613 |
+
except Exception as ex:
|
| 614 |
+
self._on_shutdown_complete(ex)
|
| 615 |
+
else:
|
| 616 |
+
if not self._get_write_buffer_size():
|
| 617 |
+
self._set_state(SHUTDOWN)
|
| 618 |
+
self._do_shutdown(context)
|
| 619 |
+
|
| 620 |
+
cdef _do_shutdown(self, object context=None):
|
| 621 |
+
"""Send close_notify and wait for the same from the peer."""
|
| 622 |
+
try:
|
| 623 |
+
# we must skip all application data (if any) before unwrap
|
| 624 |
+
self._do_read_into_void(context)
|
| 625 |
+
try:
|
| 626 |
+
self._sslobj.unwrap()
|
| 627 |
+
except ssl_SSLAgainErrors as exc:
|
| 628 |
+
self._process_outgoing()
|
| 629 |
+
else:
|
| 630 |
+
self._process_outgoing()
|
| 631 |
+
if not self._get_write_buffer_size():
|
| 632 |
+
self._on_shutdown_complete(None)
|
| 633 |
+
except Exception as ex:
|
| 634 |
+
self._on_shutdown_complete(ex)
|
| 635 |
+
|
| 636 |
+
cdef _on_shutdown_complete(self, shutdown_exc):
|
| 637 |
+
if self._shutdown_timeout_handle is not None:
|
| 638 |
+
self._shutdown_timeout_handle.cancel()
|
| 639 |
+
self._shutdown_timeout_handle = None
|
| 640 |
+
|
| 641 |
+
# we don't need the context here because TCP transport.close() should
|
| 642 |
+
# be able to call connection_made() in the right context
|
| 643 |
+
if shutdown_exc:
|
| 644 |
+
self._fatal_error(shutdown_exc, 'Error occurred during shutdown')
|
| 645 |
+
else:
|
| 646 |
+
self._transport.close()
|
| 647 |
+
|
| 648 |
+
cdef _abort(self, exc):
|
| 649 |
+
self._set_state(UNWRAPPED)
|
| 650 |
+
if self._transport is not None:
|
| 651 |
+
self._transport._force_close(exc)
|
| 652 |
+
|
| 653 |
+
# Outgoing flow
|
| 654 |
+
|
| 655 |
+
cdef _write_appdata(self, list_of_data, object context):
|
| 656 |
+
if self._state in (FLUSHING, SHUTDOWN, UNWRAPPED):
|
| 657 |
+
if self._conn_lost >= LOG_THRESHOLD_FOR_CONNLOST_WRITES:
|
| 658 |
+
aio_logger.warning('SSL connection is closed')
|
| 659 |
+
self._conn_lost += 1
|
| 660 |
+
return
|
| 661 |
+
|
| 662 |
+
for data in list_of_data:
|
| 663 |
+
self._write_backlog.append(data)
|
| 664 |
+
self._write_buffer_size += len(data)
|
| 665 |
+
|
| 666 |
+
try:
|
| 667 |
+
if self._state == WRAPPED:
|
| 668 |
+
self._do_write()
|
| 669 |
+
self._process_outgoing()
|
| 670 |
+
self._control_app_writing(context)
|
| 671 |
+
|
| 672 |
+
except Exception as ex:
|
| 673 |
+
self._fatal_error(ex, 'Fatal error on SSL protocol')
|
| 674 |
+
|
| 675 |
+
cdef _do_write(self):
|
| 676 |
+
"""Do SSL write, consumes write backlog and fills outgoing BIO."""
|
| 677 |
+
cdef size_t data_len, count
|
| 678 |
+
try:
|
| 679 |
+
while self._write_backlog:
|
| 680 |
+
data = self._write_backlog[0]
|
| 681 |
+
count = self._sslobj_write(data)
|
| 682 |
+
data_len = len(data)
|
| 683 |
+
if count < data_len:
|
| 684 |
+
if not PyMemoryView_Check(data):
|
| 685 |
+
data = PyMemoryView_FromObject(data)
|
| 686 |
+
self._write_backlog[0] = data[count:]
|
| 687 |
+
self._write_buffer_size -= count
|
| 688 |
+
else:
|
| 689 |
+
del self._write_backlog[0]
|
| 690 |
+
self._write_buffer_size -= data_len
|
| 691 |
+
except ssl_SSLAgainErrors as exc:
|
| 692 |
+
pass
|
| 693 |
+
|
| 694 |
+
cdef _process_outgoing(self):
|
| 695 |
+
"""Send bytes from the outgoing BIO."""
|
| 696 |
+
if not self._ssl_writing_paused:
|
| 697 |
+
data = self._outgoing_read()
|
| 698 |
+
if len(data):
|
| 699 |
+
self._transport.write(data)
|
| 700 |
+
|
| 701 |
+
# Incoming flow
|
| 702 |
+
|
| 703 |
+
cdef _do_read(self):
|
| 704 |
+
if self._state != WRAPPED:
|
| 705 |
+
return
|
| 706 |
+
try:
|
| 707 |
+
if not self._app_reading_paused:
|
| 708 |
+
if self._app_protocol_is_buffer:
|
| 709 |
+
self._do_read__buffered()
|
| 710 |
+
else:
|
| 711 |
+
self._do_read__copied()
|
| 712 |
+
if self._write_backlog:
|
| 713 |
+
self._do_write()
|
| 714 |
+
self._process_outgoing()
|
| 715 |
+
self._control_app_writing()
|
| 716 |
+
self._control_ssl_reading()
|
| 717 |
+
except Exception as ex:
|
| 718 |
+
self._fatal_error(ex, 'Fatal error on SSL protocol')
|
| 719 |
+
|
| 720 |
+
cdef _do_read__buffered(self):
|
| 721 |
+
cdef:
|
| 722 |
+
Py_buffer pybuf
|
| 723 |
+
bint pybuf_inited = False
|
| 724 |
+
size_t wants, offset = 0
|
| 725 |
+
int count = 1
|
| 726 |
+
object buf
|
| 727 |
+
|
| 728 |
+
buf = self._app_protocol_get_buffer(self._get_read_buffer_size())
|
| 729 |
+
wants = len(buf)
|
| 730 |
+
|
| 731 |
+
try:
|
| 732 |
+
count = self._sslobj_read(wants, buf)
|
| 733 |
+
|
| 734 |
+
if count > 0:
|
| 735 |
+
offset = count
|
| 736 |
+
if offset < wants:
|
| 737 |
+
PyObject_GetBuffer(buf, &pybuf, PyBUF_WRITABLE)
|
| 738 |
+
pybuf_inited = True
|
| 739 |
+
while offset < wants:
|
| 740 |
+
buf = PyMemoryView_FromMemory(
|
| 741 |
+
(<char*>pybuf.buf) + offset,
|
| 742 |
+
wants - offset,
|
| 743 |
+
PyBUF_WRITE)
|
| 744 |
+
count = self._sslobj_read(wants - offset, buf)
|
| 745 |
+
if count > 0:
|
| 746 |
+
offset += count
|
| 747 |
+
else:
|
| 748 |
+
break
|
| 749 |
+
else:
|
| 750 |
+
self._loop._call_soon_handle(
|
| 751 |
+
new_MethodHandle(self._loop,
|
| 752 |
+
"SSLProtocol._do_read",
|
| 753 |
+
<method_t>self._do_read,
|
| 754 |
+
None, # current context is good
|
| 755 |
+
self))
|
| 756 |
+
except ssl_SSLAgainErrors as exc:
|
| 757 |
+
pass
|
| 758 |
+
finally:
|
| 759 |
+
if pybuf_inited:
|
| 760 |
+
PyBuffer_Release(&pybuf)
|
| 761 |
+
if offset > 0:
|
| 762 |
+
self._app_protocol_buffer_updated(offset)
|
| 763 |
+
if not count:
|
| 764 |
+
# close_notify
|
| 765 |
+
self._call_eof_received()
|
| 766 |
+
self._start_shutdown()
|
| 767 |
+
|
| 768 |
+
cdef _do_read__copied(self):
|
| 769 |
+
cdef:
|
| 770 |
+
list data
|
| 771 |
+
bytes first, chunk = b'1'
|
| 772 |
+
bint zero = True, one = False
|
| 773 |
+
|
| 774 |
+
try:
|
| 775 |
+
while True:
|
| 776 |
+
chunk = self._sslobj_read(SSL_READ_MAX_SIZE)
|
| 777 |
+
if not chunk:
|
| 778 |
+
break
|
| 779 |
+
if zero:
|
| 780 |
+
zero = False
|
| 781 |
+
one = True
|
| 782 |
+
first = chunk
|
| 783 |
+
elif one:
|
| 784 |
+
one = False
|
| 785 |
+
data = [first, chunk]
|
| 786 |
+
else:
|
| 787 |
+
data.append(chunk)
|
| 788 |
+
except ssl_SSLAgainErrors as exc:
|
| 789 |
+
pass
|
| 790 |
+
if one:
|
| 791 |
+
self._app_protocol.data_received(first)
|
| 792 |
+
elif not zero:
|
| 793 |
+
self._app_protocol.data_received(b''.join(data))
|
| 794 |
+
if not chunk:
|
| 795 |
+
# close_notify
|
| 796 |
+
self._call_eof_received()
|
| 797 |
+
self._start_shutdown()
|
| 798 |
+
|
| 799 |
+
cdef _call_eof_received(self, object context=None):
|
| 800 |
+
if self._app_state == STATE_CON_MADE:
|
| 801 |
+
self._app_state = STATE_EOF
|
| 802 |
+
try:
|
| 803 |
+
if context is None:
|
| 804 |
+
# If the caller didn't provide a context, we assume the
|
| 805 |
+
# caller is already in the right context, which is usually
|
| 806 |
+
# inside the upstream callbacks like buffer_updated()
|
| 807 |
+
keep_open = self._app_protocol.eof_received()
|
| 808 |
+
else:
|
| 809 |
+
keep_open = run_in_context(
|
| 810 |
+
context, self._app_protocol.eof_received,
|
| 811 |
+
)
|
| 812 |
+
except (KeyboardInterrupt, SystemExit):
|
| 813 |
+
raise
|
| 814 |
+
except BaseException as ex:
|
| 815 |
+
self._fatal_error(ex, 'Error calling eof_received()')
|
| 816 |
+
else:
|
| 817 |
+
if keep_open:
|
| 818 |
+
aio_logger.warning('returning true from eof_received() '
|
| 819 |
+
'has no effect when using ssl')
|
| 820 |
+
|
| 821 |
+
# Flow control for writes from APP socket
|
| 822 |
+
|
| 823 |
+
cdef _control_app_writing(self, object context=None):
|
| 824 |
+
cdef size_t size = self._get_write_buffer_size()
|
| 825 |
+
if size >= self._outgoing_high_water and not self._app_writing_paused:
|
| 826 |
+
self._app_writing_paused = True
|
| 827 |
+
try:
|
| 828 |
+
if context is None:
|
| 829 |
+
# If the caller didn't provide a context, we assume the
|
| 830 |
+
# caller is already in the right context, which is usually
|
| 831 |
+
# inside the upstream callbacks like buffer_updated()
|
| 832 |
+
self._app_protocol.pause_writing()
|
| 833 |
+
else:
|
| 834 |
+
run_in_context(context, self._app_protocol.pause_writing)
|
| 835 |
+
except (KeyboardInterrupt, SystemExit):
|
| 836 |
+
raise
|
| 837 |
+
except BaseException as exc:
|
| 838 |
+
self._loop.call_exception_handler({
|
| 839 |
+
'message': 'protocol.pause_writing() failed',
|
| 840 |
+
'exception': exc,
|
| 841 |
+
'transport': self._app_transport,
|
| 842 |
+
'protocol': self,
|
| 843 |
+
})
|
| 844 |
+
elif size <= self._outgoing_low_water and self._app_writing_paused:
|
| 845 |
+
self._app_writing_paused = False
|
| 846 |
+
try:
|
| 847 |
+
if context is None:
|
| 848 |
+
# If the caller didn't provide a context, we assume the
|
| 849 |
+
# caller is already in the right context, which is usually
|
| 850 |
+
# inside the upstream callbacks like resume_writing()
|
| 851 |
+
self._app_protocol.resume_writing()
|
| 852 |
+
else:
|
| 853 |
+
run_in_context(context, self._app_protocol.resume_writing)
|
| 854 |
+
except (KeyboardInterrupt, SystemExit):
|
| 855 |
+
raise
|
| 856 |
+
except BaseException as exc:
|
| 857 |
+
self._loop.call_exception_handler({
|
| 858 |
+
'message': 'protocol.resume_writing() failed',
|
| 859 |
+
'exception': exc,
|
| 860 |
+
'transport': self._app_transport,
|
| 861 |
+
'protocol': self,
|
| 862 |
+
})
|
| 863 |
+
|
| 864 |
+
cdef size_t _get_write_buffer_size(self):
|
| 865 |
+
return self._outgoing.pending + self._write_buffer_size
|
| 866 |
+
|
| 867 |
+
cdef _set_write_buffer_limits(self, high=None, low=None):
|
| 868 |
+
high, low = add_flowcontrol_defaults(
|
| 869 |
+
high, low, FLOW_CONTROL_HIGH_WATER_SSL_WRITE)
|
| 870 |
+
self._outgoing_high_water = high
|
| 871 |
+
self._outgoing_low_water = low
|
| 872 |
+
|
| 873 |
+
# Flow control for reads to APP socket
|
| 874 |
+
|
| 875 |
+
cdef _pause_reading(self):
|
| 876 |
+
self._app_reading_paused = True
|
| 877 |
+
|
| 878 |
+
cdef _resume_reading(self, object context):
|
| 879 |
+
if self._app_reading_paused:
|
| 880 |
+
self._app_reading_paused = False
|
| 881 |
+
if self._state == WRAPPED:
|
| 882 |
+
self._loop._call_soon_handle(
|
| 883 |
+
new_MethodHandle(self._loop,
|
| 884 |
+
"SSLProtocol._do_read",
|
| 885 |
+
<method_t>self._do_read,
|
| 886 |
+
context,
|
| 887 |
+
self))
|
| 888 |
+
|
| 889 |
+
# Flow control for reads from SSL socket
|
| 890 |
+
|
| 891 |
+
cdef _control_ssl_reading(self):
|
| 892 |
+
cdef size_t size = self._get_read_buffer_size()
|
| 893 |
+
if size >= self._incoming_high_water and not self._ssl_reading_paused:
|
| 894 |
+
self._ssl_reading_paused = True
|
| 895 |
+
self._transport.pause_reading()
|
| 896 |
+
elif size <= self._incoming_low_water and self._ssl_reading_paused:
|
| 897 |
+
self._ssl_reading_paused = False
|
| 898 |
+
self._transport.resume_reading()
|
| 899 |
+
|
| 900 |
+
cdef _set_read_buffer_limits(self, high=None, low=None):
|
| 901 |
+
high, low = add_flowcontrol_defaults(
|
| 902 |
+
high, low, FLOW_CONTROL_HIGH_WATER_SSL_READ)
|
| 903 |
+
self._incoming_high_water = high
|
| 904 |
+
self._incoming_low_water = low
|
| 905 |
+
|
| 906 |
+
cdef size_t _get_read_buffer_size(self):
|
| 907 |
+
return self._incoming.pending
|
| 908 |
+
|
| 909 |
+
# Flow control for writes to SSL socket
|
| 910 |
+
|
| 911 |
+
def pause_writing(self):
|
| 912 |
+
"""Called when the low-level transport's buffer goes over
|
| 913 |
+
the high-water mark.
|
| 914 |
+
"""
|
| 915 |
+
assert not self._ssl_writing_paused
|
| 916 |
+
self._ssl_writing_paused = True
|
| 917 |
+
|
| 918 |
+
def resume_writing(self):
|
| 919 |
+
"""Called when the low-level transport's buffer drains below
|
| 920 |
+
the low-water mark.
|
| 921 |
+
"""
|
| 922 |
+
assert self._ssl_writing_paused
|
| 923 |
+
self._ssl_writing_paused = False
|
| 924 |
+
|
| 925 |
+
if self._state == WRAPPED:
|
| 926 |
+
self._process_outgoing()
|
| 927 |
+
self._control_app_writing()
|
| 928 |
+
|
| 929 |
+
elif self._state == FLUSHING:
|
| 930 |
+
self._do_flush()
|
| 931 |
+
|
| 932 |
+
elif self._state == SHUTDOWN:
|
| 933 |
+
self._do_shutdown()
|
| 934 |
+
|
| 935 |
+
cdef _fatal_error(self, exc, message='Fatal error on transport'):
|
| 936 |
+
if self._app_transport:
|
| 937 |
+
self._app_transport._force_close(exc)
|
| 938 |
+
elif self._transport:
|
| 939 |
+
self._transport._force_close(exc)
|
| 940 |
+
|
| 941 |
+
if isinstance(exc, OSError):
|
| 942 |
+
if self._loop.get_debug():
|
| 943 |
+
aio_logger.debug("%r: %s", self, message, exc_info=True)
|
| 944 |
+
elif not isinstance(exc, aio_CancelledError):
|
| 945 |
+
self._loop.call_exception_handler({
|
| 946 |
+
'message': message,
|
| 947 |
+
'exception': exc,
|
| 948 |
+
'transport': self._transport,
|
| 949 |
+
'protocol': self,
|
| 950 |
+
})
|
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
uv
|
personalPromptBoost/.venv/lib/python3.13/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status :: 5 - Production/Stable
|
| 5 |
+
Classifier: Environment :: Console
|
| 6 |
+
Classifier: Programming Language :: Python
|
| 7 |
+
Classifier: Programming Language :: Python :: 3
|
| 8 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 9 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 10 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 11 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 12 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 13 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 15 |
+
Classifier: Intended Audience :: Developers
|
| 16 |
+
Classifier: Intended Audience :: Information Technology
|
| 17 |
+
Classifier: Intended Audience :: System Administrators
|
| 18 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 19 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 20 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 21 |
+
Classifier: Operating System :: MacOS
|
| 22 |
+
Classifier: Environment :: MacOS X
|
| 23 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 24 |
+
Classifier: Topic :: System :: Filesystems
|
| 25 |
+
Classifier: Framework :: AnyIO
|
| 26 |
+
Requires-Dist: anyio>=3.0.0
|
| 27 |
+
License-File: LICENSE
|
| 28 |
+
Summary: Simple, modern and high performance file watching and code reload in python.
|
| 29 |
+
Home-Page: https://github.com/samuelcolvin/watchfiles
|
| 30 |
+
Author-email: Samuel Colvin <s@muelcolvin.com>
|
| 31 |
+
License: MIT
|
| 32 |
+
Requires-Python: >=3.9
|
| 33 |
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
| 34 |
+
Project-URL: Homepage, https://github.com/samuelcolvin/watchfiles
|
| 35 |
+
Project-URL: Documentation, https://watchfiles.helpmanual.io
|
| 36 |
+
Project-URL: Funding, https://github.com/sponsors/samuelcolvin
|
| 37 |
+
Project-URL: Source, https://github.com/samuelcolvin/watchfiles
|
| 38 |
+
Project-URL: Changelog, https://github.com/samuelcolvin/watchfiles/releases
|
| 39 |
+
|
| 40 |
+
# watchfiles
|
| 41 |
+
|
| 42 |
+
[](https://github.com/samuelcolvin/watchfiles/actions/workflows/ci.yml?query=branch%3Amain)
|
| 43 |
+
[](https://codecov.io/gh/samuelcolvin/watchfiles)
|
| 44 |
+
[](https://pypi.python.org/pypi/watchfiles)
|
| 45 |
+
[](https://anaconda.org/conda-forge/watchfiles)
|
| 46 |
+
[](https://github.com/samuelcolvin/watchfiles/blob/main/LICENSE)
|
| 47 |
+
|
| 48 |
+
Simple, modern and high performance file watching and code reload in python.
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
**Documentation**: [watchfiles.helpmanual.io](https://watchfiles.helpmanual.io)
|
| 53 |
+
|
| 54 |
+
**Source Code**: [github.com/samuelcolvin/watchfiles](https://github.com/samuelcolvin/watchfiles)
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
Underlying file system notifications are handled by the [Notify](https://github.com/notify-rs/notify) rust library.
|
| 59 |
+
|
| 60 |
+
This package was previously named "watchgod",
|
| 61 |
+
see [the migration guide](https://watchfiles.helpmanual.io/migrating/) for more information.
|
| 62 |
+
|
| 63 |
+
## Installation
|
| 64 |
+
|
| 65 |
+
**watchfiles** requires Python 3.9 - 3.14.
|
| 66 |
+
|
| 67 |
+
```bash
|
| 68 |
+
pip install watchfiles
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
Binaries are available for most architectures on Linux, MacOS and Windows ([learn more](https://watchfiles.helpmanual.io/#installation)).
|
| 72 |
+
|
| 73 |
+
Otherwise, you can install from source which requires Rust stable to be installed.
|
| 74 |
+
|
| 75 |
+
## Usage
|
| 76 |
+
|
| 77 |
+
Here are some examples of what **watchfiles** can do:
|
| 78 |
+
|
| 79 |
+
### `watch` Usage
|
| 80 |
+
|
| 81 |
+
```py
|
| 82 |
+
from watchfiles import watch
|
| 83 |
+
|
| 84 |
+
for changes in watch('./path/to/dir'):
|
| 85 |
+
print(changes)
|
| 86 |
+
```
|
| 87 |
+
See [`watch` docs](https://watchfiles.helpmanual.io/api/watch/#watchfiles.watch) for more details.
|
| 88 |
+
|
| 89 |
+
### `awatch` Usage
|
| 90 |
+
|
| 91 |
+
```py
|
| 92 |
+
import asyncio
|
| 93 |
+
from watchfiles import awatch
|
| 94 |
+
|
| 95 |
+
async def main():
|
| 96 |
+
async for changes in awatch('/path/to/dir'):
|
| 97 |
+
print(changes)
|
| 98 |
+
|
| 99 |
+
asyncio.run(main())
|
| 100 |
+
```
|
| 101 |
+
See [`awatch` docs](https://watchfiles.helpmanual.io/api/watch/#watchfiles.awatch) for more details.
|
| 102 |
+
|
| 103 |
+
### `run_process` Usage
|
| 104 |
+
|
| 105 |
+
```py
|
| 106 |
+
from watchfiles import run_process
|
| 107 |
+
|
| 108 |
+
def foobar(a, b, c):
|
| 109 |
+
...
|
| 110 |
+
|
| 111 |
+
if __name__ == '__main__':
|
| 112 |
+
run_process('./path/to/dir', target=foobar, args=(1, 2, 3))
|
| 113 |
+
```
|
| 114 |
+
See [`run_process` docs](https://watchfiles.helpmanual.io/api/run_process/#watchfiles.run_process) for more details.
|
| 115 |
+
|
| 116 |
+
### `arun_process` Usage
|
| 117 |
+
|
| 118 |
+
```py
|
| 119 |
+
import asyncio
|
| 120 |
+
from watchfiles import arun_process
|
| 121 |
+
|
| 122 |
+
def foobar(a, b, c):
|
| 123 |
+
...
|
| 124 |
+
|
| 125 |
+
async def main():
|
| 126 |
+
await arun_process('./path/to/dir', target=foobar, args=(1, 2, 3))
|
| 127 |
+
|
| 128 |
+
if __name__ == '__main__':
|
| 129 |
+
asyncio.run(main())
|
| 130 |
+
```
|
| 131 |
+
See [`arun_process` docs](https://watchfiles.helpmanual.io/api/run_process/#watchfiles.arun_process) for more details.
|
| 132 |
+
|
| 133 |
+
## CLI
|
| 134 |
+
|
| 135 |
+
**watchfiles** also comes with a CLI for running and reloading code. To run `some command` when files in `src` change:
|
| 136 |
+
|
| 137 |
+
```
|
| 138 |
+
watchfiles "some command" src
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
For more information, see [the CLI docs](https://watchfiles.helpmanual.io/cli/).
|
| 142 |
+
|
| 143 |
+
Or run
|
| 144 |
+
|
| 145 |
+
```bash
|
| 146 |
+
watchfiles --help
|
| 147 |
+
```
|
| 148 |
+
|
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/watchfiles,sha256=2DopBI6smGoTRR5lGV6SSsfspTZ30quNa5yfiFkQVeg,348
|
| 2 |
+
watchfiles-1.1.1.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
|
| 3 |
+
watchfiles-1.1.1.dist-info/METADATA,sha256=h34wYtQyezaYEn9GQWg8z4d9JCViFLT4vmKd_ip6WF8,4874
|
| 4 |
+
watchfiles-1.1.1.dist-info/RECORD,,
|
| 5 |
+
watchfiles-1.1.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
watchfiles-1.1.1.dist-info/WHEEL,sha256=7Vw0WRntmSve_iXr_rQ5FAz3aRtHeuje9S7jZ9QJVqI,129
|
| 7 |
+
watchfiles-1.1.1.dist-info/entry_points.txt,sha256=s1Dpa2d_KKBy-jKREWW60Z3GoRZ3JpCEo_9iYDt6hOQ,48
|
| 8 |
+
watchfiles-1.1.1.dist-info/licenses/LICENSE,sha256=T9eDVbZ84md-3p-29jolDzd7t-IgiBNqX0aZrbS8Bp8,1091
|
| 9 |
+
watchfiles/__init__.py,sha256=IRlM9KOSedMzF1fvLr7yEHPVS-UFERNThlB-tmWI8yU,364
|
| 10 |
+
watchfiles/__main__.py,sha256=JgErYkiskih8Y6oRwowALtR-rwQhAAdqOYWjQraRIPI,59
|
| 11 |
+
watchfiles/_rust_notify.cpython-313-x86_64-linux-gnu.so,sha256=zrjA-ggFEPTV3ype9fkGiWSWm9XJKsHEoKF1zsxNdoQ,1124208
|
| 12 |
+
watchfiles/_rust_notify.pyi,sha256=q5FQkXgBJEFPt9RCf7my4wP5RM1FwSVpqf221csyebg,4753
|
| 13 |
+
watchfiles/cli.py,sha256=DHMI0LfT7hOrWai_Y4RP_vvTvVdtcDaioixXLiv2pG4,7707
|
| 14 |
+
watchfiles/filters.py,sha256=U0zXGOeg9dMHkT51-56BKpRrWIu95lPq0HDR_ZB4oDE,5139
|
| 15 |
+
watchfiles/main.py,sha256=-pbJBFBA34VEXMt8VGcaPTQHAjsGhPf7Psu1gP_HnKk,15235
|
| 16 |
+
watchfiles/py.typed,sha256=MS4Na3to9VTGPy_8wBQM_6mNKaX4qIpi5-w7_LZB-8I,69
|
| 17 |
+
watchfiles/run.py,sha256=TLXb2y_xYx-t3xyszVQWHoGyG7RCb107Q0NoIcSWmjQ,15348
|
| 18 |
+
watchfiles/version.py,sha256=NRWUnkZ32DamsNKV20EetagIGTLDMMUnqDWVGFFA2WQ,85
|
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/REQUESTED
ADDED
|
File without changes
|
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: maturin (1.9.6)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64
|
personalPromptBoost/.venv/lib/python3.13/site-packages/watchfiles-1.1.1.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
watchfiles=watchfiles.cli:cli
|