Skip to content

Commit 70c259d

Browse files
committed
Fix caching bug in Client API that would cause the section properties to be shared between all client objects (causing the wrong endpoint to receive the calls!)
1 parent 63cfd4d commit 70c259d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ipfshttpclient/client/base.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88

99
class SectionProperty(object):
1010
def __init__(self, cls):
11-
self.cls = cls
12-
self.instance = None
11+
self.cls = cls
1312

1413
def __get__(self, client_object, type=None):
15-
if not self.instance:
16-
self.instance = self.cls(client_object)
17-
18-
return self.instance
14+
try:
15+
return client_object.__prop_objs__[self]
16+
except AttributeError:
17+
client_object.__prop_objs__ = {
18+
self: self.cls(client_object)
19+
}
20+
return client_object.__prop_objs__[self]
21+
except KeyError:
22+
client_object.__prop_objs__[self] = self.cls(client_object)
23+
return client_object.__prop_objs__[self]
1924

2025

2126
class SectionBase(object):

0 commit comments

Comments
 (0)