巴扎黑2017-04-17 17:54:39
Single cases are generally used in situations like connections. The scenario where I used singletons in python web before was that the python web service needed to connect to another service and needed to register and log in. At this time, if a singleton was not used, every client would send a request to that server through the web program. The service registers and logs in. After using the singleton, all clients only register and log in once with another service through the web, and then use this connection repeatedly until the connection expires.