Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update singleton_thread_locals.py #252

Merged
merged 3 commits into from Jun 17, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/providers/singleton_thread_locals.py
@@ -1,7 +1,7 @@
"""`ThreadLocalSingleton` providers example."""

import threading
import Queue
import queue

import dependency_injector.providers as providers

Expand All @@ -15,7 +15,7 @@ def example(example_object, queue):
thread_local_object = providers.ThreadLocalSingleton(object)

# Create singleton provider for thread-safe queue:
queue = providers.Singleton(Queue.Queue)
queue = providers.ThreadSafeSingleton(queue.Queue)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rename queue to queue_factory. As of now, queue variable overrides the name of the imported module. It's a bad practice. Also queue_factory name will be consistent with thread_factory at line 26.


# Create callable provider for example(), inject dependencies:
example = providers.DelegatedCallable(example,
Expand Down