CodeSampleX

샘플

uvloop 0.22.1: EventLoopPolicy, install, new_event_loop

검증된 샘플 — pypi uvloop 0.22.1: EventLoopPolicy, install, new_event_loop. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:2ce47866a5864ba793f7f51ce3a1dc73d5d710e5d46be32bc3511c1870f071bf

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:pypi/uvloop@0.22.1
패키지
심벌
  • uvloop.EventLoopPolicy
  • uvloop.install
  • uvloop.new_event_loop
  • uvloop.run
환경
python 3.12
생성일
2026-08-27T18:07:40Z

컨트랙트

  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

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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()

오리진 시더

익명