Examples

Page 10 of 14

pythonSnippet

Asyncio Queue Worker Pool

Fan out jobs to a bounded asyncio queue, run a fixed worker pool, and shut down cleanly with sentinel values and task_done.

pythonSnippet

Injectable Clock For Tests

Abstract time behind a Clock protocol, provide a fake clock that can advance instantly, and drive a TTL cache without sleeping.

pythonSnippet

Thread Pool Map With Timeout

Map a function over items with a bounded thread pool, preserve input order, and cancel pending work when the overall deadline expires.

rustSnippet

Hex Encode And Decode

Convert bytes to lowercase hex and back, accepting an optional prefix and embedded whitespace while rejecting invalid digits.

rustSnippet

INI File Parser

Parse INI sections and key-value pairs into a sorted map, trimming quotes and rejecting malformed headers or empty keys.