Bug
In tests/units/test_inner.py, test_thread_safety uses:
threads = [Thread(target=go_increment()) for _ in range(number_of_threads)]
go_increment() is called immediately when building the list (it runs all 10,000 iterations in the main thread for each of the 10 list items). Its return value is None, so each thread is created with target=None. When the threads start, they run nothing.
As a result:
- All
InnerNoneType() instances are created in the main thread.
- The test never exercises concurrent id generation.
- Thread safety of
itertools.count() / next(self.counter) is untested.
Fix
Pass the callable instead of calling it:
threads = [Thread(target=go_increment) for _ in range(number_of_threads)]
Then each thread will run go_increment() and the test will actually verify that unique ids are generated under concurrency.
Bug
In
tests/units/test_inner.py,test_thread_safetyuses:go_increment()is called immediately when building the list (it runs all 10,000 iterations in the main thread for each of the 10 list items). Its return value isNone, so each thread is created withtarget=None. When the threads start, they run nothing.As a result:
InnerNoneType()instances are created in the main thread.itertools.count()/next(self.counter)is untested.Fix
Pass the callable instead of calling it:
Then each thread will run
go_increment()and the test will actually verify that unique ids are generated under concurrency.