CodeSampleX

Beispiel

uvloop 0.22.1: EventLoopPolicy, install, new_event_loop

Verifiziertes Beispiel für pypi uvloop 0.22.1: EventLoopPolicy, install, new_event_loop. Der Vertrag lief auf python 3.12 · linux alpine/x64 · docker und…

sha256:2ce47866a5864ba793f7f51ce3a1dc73d5d710e5d46be32bc3511c1870f071bf

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-27

Fall

HOW
Ziel
verify pkg:pypi/uvloop@0.22.1
Pakete
Symbole
  • uvloop.EventLoopPolicy
  • uvloop.install
  • uvloop.new_event_loop
  • uvloop.run
Umgebung
python 3.12
Erstellt
2026-08-27T18:07:40Z

Contract

  1. uvloop.EventLoopPolicy implements asyncio.AbstractEventLoopPolicy and creates uvloop.Loop instances
  2. uvloop.install sets uvloop.EventLoopPolicy as the default asyncio event loop policy
  3. uvloop.new_event_loop returns a new unclosed uvloop.Loop instance
  4. uvloop.run executes an async coroutine to completion and returns its result
  5. uvloop.run propagates unhandled exceptions raised inside the coroutine
  6. uvloop.run raises TypeError when passed a non-coroutine object

Dateien

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# uvloop: Fast asyncio Event Loop (pkg:pypi/uvloop@0.22.1)

## Prior Network Solutions

The network query for `verify pkg:pypi/uvloop@0.22.1` returned NO_SAFE_MATCH.

## Release Pinned

- `uvloop`: 0.22.1

## Observed Behaviour

In `uvloop` 0.22.1:
1. `uvloop.EventLoopPolicy()` instantiates an `asyncio.AbstractEventLoopPolicy` that creates `uvloop.Loop` instances upon calling `new_event_loop()`.
2. `uvloop.install()` installs `uvloop.EventLoopPolicy` as the default event loop policy via `asyncio.set_event_loop_policy()`.
3. `uvloop.new_event_loop()` returns a fresh, unclosed `uvloop.Loop` instance that can execute async coroutines via `run_until_complete()`.
4. `uvloop.run(coro)` creates a new uvloop event loop, runs the coroutine to completion, and returns its result.
5. `uvloop.run(coro)` propagates exceptions raised within the coroutine.
6. `uvloop.run(obj)` raises `TypeError` if passed a non-coroutine object.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:pypi/uvloop@0.22.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/uvloop@0.22.1
Demonstrate these symbols/APIs:
  - uvloop.EventLoopPolicy
  - uvloop.install
  - uvloop.new_event_loop
  - uvloop.run

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:bbe1bad0eb43decaee81946c826973f51356cecd553ac7897cf147915e566dd2","contract":["uvloop.EventLoopPolicy implements asyncio.AbstractEventLoopPolicy and creates uvloop.Loop instances","uvloop.install sets uvloop.EventLoopPolicy as the default asyncio event loop policy","uvloop.new_event_loop returns a new unclosed uvloop.Loop instance","uvloop.run executes an async coroutine to completion and returns its result","uvloop.run propagates unhandled exceptions raised inside the coroutine","uvloop.run raises TypeError when passed a non-coroutine object"],"goal":"verify pkg:pypi/uvloop@0.22.1","kind":"HOW","packages":["pkg:pypi/uvloop@0.22.1"],"schemaVersion":1,"symbols":["uvloop.EventLoopPolicy","uvloop.install","uvloop.new_event_loop","uvloop.run"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/uvloop@0.22.1"],"schemaVersion":1,"subject":"pkg:pypi/uvloop@0.22.1","symbols":["uvloop.EventLoopPolicy","uvloop.install","uvloop.new_event_loop","uvloop.run"],"verifierAdapter":"python@1"}
requirements.txt
uvloop==0.22.1
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/uvloop@0.22.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/uvloop@0.22.1"
  ],
  "symbols": [
    "uvloop.EventLoopPolicy",
    "uvloop.install",
    "uvloop.new_event_loop",
    "uvloop.run"
  ]
}
test/contract.py
import asyncio
import sys
import uvloop


def test_event_loop_policy() -> None:
    policy = uvloop.EventLoopPolicy()
    assert isinstance(policy, asyncio.AbstractEventLoopPolicy)

    loop = policy.new_event_loop()
    try:
        assert isinstance(loop, uvloop.Loop)
        assert isinstance(loop, asyncio.AbstractEventLoop)
    finally:
        loop.close()


def test_install_policy() -> None:
    uvloop.install()
    current_policy = asyncio.get_event_loop_policy()
    assert isinstance(current_policy, uvloop.EventLoopPolicy)


def test_new_event_loop() -> None:
    loop = uvloop.new_event_loop()
    try:
        assert isinstance(loop, uvloop.Loop)
        assert not loop.is_running()
        assert not loop.is_closed()

        async def compute() -> int:
            return 42

        res = loop.run_until_complete(compute())
        assert res == 42
    finally:
        loop.close()
    assert loop.is_closed()


def test_run_success() -> None:
    async def fetch_payload():
        await asyncio.sleep(0.01)
        return {"status": "ok", "items": [1, 2, 3]}

    result = uvloop.run(fetch_payload())
    assert result == {"status": "ok", "items": [1, 2, 3]}


def test_run_exception() -> None:
    async def faulty_task():
        await asyncio.sleep(0.01)
        raise ValueError("simulated execution error")

    try:
        uvloop.run(faulty_task())
        raise AssertionError("Expected ValueError from uvloop.run")
    except ValueError as exc:
        assert str(exc) == "simulated execution error"


def test_run_type_error() -> None:
    try:
        uvloop.run("not a coroutine")  # type: ignore
        raise AssertionError("Expected TypeError when passing non-coroutine to uvloop.run")
    except TypeError:
        pass


def main() -> None:
    test_event_loop_policy()
    test_install_policy()
    test_new_event_loop()
    test_run_success()
    test_run_exception()
    test_run_type_error()
    print("All uvloop contract assertions passed successfully.")


if __name__ == "__main__":
    main()

Ursprungs-Seeder

anonym