class Borg: _shared_data = {} # Attribute_shared_data # Make it an attribute dictionary
class Singleton(Borg): #Inherits from the BorgWhy is borg initial
类似的问题已经被问了很多次,但我在理解它方面存在问题。我在想,Singleton或Borg模式可以用来只创建对象的一个实例,或者共享它的状态。我有一个(正在工作的)测试示例,它不能像我期望的那样工作。要么是代码不正确,要么是我误解了singleton/borg模式的概念。我使用和模式在borg.py文件中创建了以下代码
class Singleton(o
python如何将属性val1和val2添加到类中。python内部是否会调用b1.__shared_state'val1‘= 'Jaga Gola!’之类的东西?# Borg (monostate pattern) lets a class have as many instances as one likes,
b2 = Borg()
b1.v
尝试使用borg将机器1备份到远程机器2(即语法),给出了错误Connection closed by remote host.Is borg working on the server?
所有权限和防火墙都经过了测试。Machine1可以从ssh到Machine2,但是当尝试从Machine1执行borg init --encryption=repokey borgdemo@Machine2:.尝试在Machine2上使用borg