You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting the following error while initializing the container that contains instances that cannot be pickled. Is there a requirement that all the instances created within the container should be picklable?
Version used: 4.41.0
class DependencyContainer(containers.DeclarativeContainer):
metric_flow_client = providers.Singleton(
MetricFlowClient,
sql_client=SnowflakeSqlClient.from_config(mf_snowflake_config)
)
if __name__ == "__main__":
container = DependencyContainer(). <---- Fails here
container.init_resources()
container.wire(modules=[__name__])
Error log:
Traceback (most recent call last):
File "/Users/arunkumar/Projects/unified-metrics-platform/consumption_grpc/grpc_server.py", line 79, in <module>
container = DependencyContainer()
File "src/dependency_injector/containers.pyx", line 730, in dependency_injector.containers.DeclarativeContainer.__new__
File "src/dependency_injector/providers.pyx", line 4913, in dependency_injector.providers.deepcopy
File "src/dependency_injector/providers.pyx", line 4920, in dependency_injector.providers.deepcopy
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 153, in deepcopy
y = copier(memo)
File "src/dependency_injector/providers.pyx", line 2835, in dependency_injector.providers.BaseSingleton.__deepcopy__
File "src/dependency_injector/providers.pyx", line 4920, in dependency_injector.providers.deepcopy
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/arunkumar/.pyenv/versions/3.9.10/lib/python3.9/copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: cannot pickle '_thread.lock' object
Thanks for the help!
The text was updated successfully, but these errors were encountered:
I've had the same problem, but with pymongo'sCollection class. Ended up using providers.Callable and wrapping the object creation in a function, as they are picklable:
Getting the following error while initializing the container that contains instances that cannot be pickled. Is there a requirement that all the instances created within the container should be picklable?
Version used: 4.41.0
Error log:
Thanks for the help!
The text was updated successfully, but these errors were encountered: