Skip to content

Commit

Permalink
[API] Remove ObjectMap storage due to memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Jan 20, 2016
1 parent 7d0e332 commit e0c98dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions grapheneapi/grapheneclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,18 @@ def getObject(self, oid):
""" Get an Object either from Websocket store (if available) or
from RPC connection.
"""
print(self.ws)
if self.ws :
[_instance, _type, _id] = oid.split(".")
if (not (oid in self.ws.proto.objectMap) or
_instance == "1" and _type == "7"): # force refresh orders
data = self.rpc.get_object(oid)
self.ws.proto.objectMap[oid] = data
else:
data = self.ws.proto.objectMap[oid]
if len(data) == 1 :
return data[0]
else:
return data
# [_instance, _type, _id] = oid.split(".")
# if (not (oid in self.ws.proto.objectMap) or
# _instance == "1" and _type == "7"): # force refresh orders
# data = self.rpc.get_object(oid)
# self.ws.proto.objectMap[oid] = data
# else:
# data = self.ws.proto.objectMap[oid]
# if len(data) == 1 :
# return data[0]
# else:
# return data
return self.ws.get_objects([oid])[0]
else :
return self.rpc.get_object(oid)[0]
18 changes: 9 additions & 9 deletions grapheneapi/graphenewsprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ def getObjectcb(self, oid, callback, *args):
:param object-id oid: Object ID to retrieve
:param fnt callback: Callback to call if object has been received
"""
if oid in self.objectMap and callable(callback):
callback(self.objectMap[oid])
else:
handles = [partial(self.setObject, oid)]
if callback and callable(callback):
handles.append(callback)
self.wsexec([self.api_ids["database"],
"get_objects",
[[oid]]], handles)
# if oid in self.objectMap and callable(callback):
# callback(self.objectMap[oid])
# else:
handles = [partial(self.setObject, oid)]
if callback and callable(callback):
handles.append(callback)
self.wsexec([self.api_ids["database"],
"get_objects",
[[oid]]], handles)

def setObject(self, oid, data):
""" Set Object in the internal Object Storage
Expand Down

0 comments on commit e0c98dd

Please sign in to comment.