6 # This module is commonly used by others in here and should avoid
7 # taking any unnecessary dependencies back on them.
9 logger = logging.getLogger(__name__)
13 def get(name: str) -> int:
15 Returns a thread safe monotonically increasing id suitable for use
16 as a globally unique identifier.
18 >>> import id_generator
19 >>> id_generator.get('student_id')
21 >>> id_generator.get('student_id')
24 if name not in generators:
25 generators[name] = itertools.count()
26 x = next(generators[name])
27 logger.debug(f"Generated next id {x}")
31 if __name__ == '__main__':