Skip to content

Bug: test_thread_safety does not run any concurrent code #9

@eddiethedean

Description

@eddiethedean

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions