MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / _PolledWorkResource

Class _PolledWorkResource

tests/lib/environments/test_worker.py:1235–1252  ·  view source on GitHub ↗

The work resource of a client that has spans, which answers the worker's polls with `items`.

Source from the content-addressed store, hash-verified

1233
1234
1235class _PolledWorkResource(_FakeWorkResource):
1236 """The work resource of a client that has spans, which answers the worker's polls with `items`."""
1237
1238 def __init__(self, spans: Spans, items: list[Any], **kwargs: Any) -> None:
1239 super().__init__(**kwargs)
1240 self._client = SimpleNamespace(
1241 _tracer=spans.provider.get_tracer("sdk"),
1242 _otel=OpenTelemetryConfig(resolve_open_telemetry(None), provider_name="anthropic"),
1243 )
1244 self._items = list(items)
1245
1246 async def poll(self, _environment_id: str, **_kwargs: Any) -> Any:
1247 if not self._items:
1248 raise _StopRun
1249 return self._items.pop(0)
1250
1251 async def ack(self, work_id: str, **_kwargs: Any) -> None:
1252 pass
1253
1254
1255def _polling_worker(monkeypatch: pytest.MonkeyPatch, work: _PolledWorkResource, serve: Any) -> EnvironmentWorker:

Calls

no outgoing calls