#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""A helper class for generating thread safe monotonically increasing
+id numbers.
+
+"""
+
import itertools
import logging
def get(name: str, *, start=0) -> int:
"""
- Returns a thread safe monotonically increasing id suitable for use
+ Returns a thread-safe, monotonically increasing id suitable for use
as a globally unique identifier.
>>> import id_generator
if name not in generators:
generators[name] = itertools.count(start, 1)
x = next(generators[name])
- logger.debug(f"Generated next id {x}")
+ logger.debug("Generated next id %d", x)
return x