{"id":10234,"library":"smithy-aws-event-stream","title":"Smithy AWS Event Stream","description":"Smithy AWS Event Stream provides components for interacting with Amazon Event Streams. It handles the serialization and deserialization of event stream messages according to the AWS Event Stream specification. This library is part of the broader `smithy-python` project, currently at version 0.2.1, with a release cadence tied to the evolution of the `smithy-python` ecosystem.","status":"active","version":"0.2.1","language":"en","source_language":"en","source_url":"https://github.com/smithy-lang/smithy-python/tree/develop/packages/smithy-aws-event-stream/","tags":["aws","event-stream","smithy","serialization","async"],"install":[{"cmd":"pip install smithy-aws-event-stream","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for low-level event stream protocol handling.","package":"aws-eventstream"},{"reason":"Used for calculating and verifying event stream checksums.","package":"aws-checksums"},{"reason":"Primary framework dependency providing base types, interfaces, and integration points for Smithy clients and services.","package":"smithy-python"}],"imports":[{"note":"Core data model classes are nested under the `model` submodule, not directly at the top level.","wrong":"from smithy_aws_event_stream import EventStreamMessage","symbol":"EventStreamMessage","correct":"from smithy_aws_event_stream.model import EventStreamMessage"},{"note":"The serializer/deserializer class is in the `serde` submodule and typically used within a `smithy-python` generated client.","symbol":"EventStreamSerde","correct":"from smithy_aws_event_stream.serde import EventStreamSerde"}],"quickstart":{"code":"from smithy_aws_event_stream.model import EventStreamMessage, EventStreamHeader, EventStreamHeaderValue\n\n# 1. Create headers for the event stream message\nheaders = [\n    EventStreamHeader(name=\":message-type\", value=EventStreamHeaderValue.string(\"event\")),\n    EventStreamHeader(name=\":event-type\", value=EventStreamHeaderValue.string(\"MyApplicationEvent\")),\n    EventStreamHeader(name=\"correlation-id\", value=EventStreamHeaderValue.uuid(\"a1b2c3d4-e5f6-7890-1234-567890abcdef\")),\n    EventStreamHeader(name=\"is-urgent\", value=EventStreamHeaderValue.boolean(True)),\n    EventStreamHeader(name=\"sequence-number\", value=EventStreamHeaderValue.int64(1))\n]\n\n# 2. Define the payload (can be empty or any bytes)\npayload = b'{\"data\": \"This is my event payload!\"}'\n\n# 3. Create an EventStreamMessage instance\nmessage = EventStreamMessage(headers=headers, payload=payload)\n\nprint(\"Created Event Stream Message:\")\nprint(f\"  Payload: {message.payload.decode('utf-8')}\")\nprint(\"  Headers:\")\nfor header in message.headers:\n    # Using to_python() to get the native Python value from EventStreamHeaderValue\n    print(f\"    - {header.name}: {header.value.to_python()}\")\n\n# In a real-world scenario, this message would typically be serialized\n# by an EventStreamSerde instance (part of an AWS client generated by smithy-python)\n# and sent over an asynchronous stream to an AWS service.","lang":"python","description":"This quickstart demonstrates how to construct a basic `EventStreamMessage` using the library's data models. This message can then be serialized and sent over an event stream, typically within the context of an AWS client generated by `smithy-python`."},"warnings":[{"fix":"Always refer to the latest `CHANGELOG.md` in the `smithy-python` repository and pin your dependencies to specific versions to mitigate unexpected breakage.","message":"As a pre-1.0 library (0.x.x versioning), API stability is not guaranteed. Expect breaking changes between minor versions (e.g., 0.1.x to 0.2.x) as the library evolves.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure your development and deployment environments are running Python 3.12 or a newer compatible version.","message":"This library requires Python 3.12 or higher. Attempting to install or run it on older Python versions will result in dependency resolution failures or runtime errors.","severity":"gotcha","affected_versions":"<0.1.0 to current"},{"fix":"Familiarize yourself with Python's `asyncio` and `async`/`await` patterns. Always use `async for` when iterating over `EventStreamSerde` or similar async iterators, and properly `await` async functions.","message":"The library is designed for asynchronous I/O and heavily uses async iterators/generators for handling event streams. Incorrect handling of asynchronous patterns (e.g., missing `await`, improper loop management) can lead to unexpected behavior, resource leaks, or deadlocks.","severity":"gotcha","affected_versions":"<0.1.0 to current"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Upgrade your Python installation to version 3.12 or higher, or use a virtual environment configured with a compatible Python version.","cause":"Your current Python environment does not meet the minimum requirement of Python 3.12 for this library.","error":"ERROR: Package 'smithy-aws-event-stream' requires a different Python: ..."},{"fix":"These classes are located in the `model` submodule. Use `from smithy_aws_event_stream.model import EventStreamMessage`.","cause":"You are trying to import `EventStreamMessage` (or similar data model classes) directly from the top-level package.","error":"AttributeError: module 'smithy_aws_event_stream' has no attribute 'EventStreamMessage'"},{"fix":"Use the `async for` syntax within an `async` function to correctly iterate over asynchronous iterators: `async for message in async_iterator: ...`","cause":"You are attempting to iterate over an asynchronous generator or iterator (like `EventStreamSerde`) using a synchronous `for` loop.","error":"TypeError: object async_generator is not iterable"}]}