Open jearistiz opened 3 years ago
Singleton pattern is probably not a good idea when using pymongo: https://pymongo.readthedocs.io/en/stable/faq.html#using-pymongo-with-multiprocessing
Patterns I Hate # 1: Singleton
We already implemented the singleton but there are a lot of bad comments on this practice, even when using it for DB connections. The best alternative is just creating one instance of the db connection and pass it to all parts of code that need it.
The code will be easy to refactor given the current circumstances. We just get rid of the Singleton
inheritance in MongoClientSingleton
and rename some variables.
Connection to mongodb could be done by means of a singleton. Verify if this is needed, and implement the singleton if needed.