Skip to content

Commit

Permalink
Reenable rpc handling of data and fix rpc threadsafe call.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeyer committed Jun 12, 2024
1 parent b3c829b commit 83dda92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nionlib/Pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def call_method(cls, proxy, object, method, *args, **kwargs):
@classmethod
def call_threadsafe_method(cls, proxy, object, method, *args, **kwargs):
try:
return Unpickler.unpickle(proxy, proxy.call_method_threadsafe(Pickler.pickle(object), method, Pickler.pickle(args), Pickler.pickle(kwargs)))
return Unpickler.unpickle(proxy, proxy.call_threadsafe_method(Pickler.pickle(object), method, Pickler.pickle(args), Pickler.pickle(kwargs)))
except xmlrpc.client.Fault as e:
error_type, error_string = e.faultString.split(":", 1)
if error_type == "<class 'TimeoutError'>":
Expand Down
6 changes: 3 additions & 3 deletions nionlib/Structs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import base64
import copy
import datetime
import pickle
import re
import numpy


class Calibration:
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self, data_fn, data_shape_and_dtype, intensity_calibration, dimensi
def from_rpc_dict(cls, d):
if d is None:
return None
data = numpy.loads(base64.b64decode(d["data"].encode('utf-8')))
data = pickle.loads(base64.b64decode(d["data"].encode('utf-8')))
data_shape_and_dtype = data.shape, data.dtype # TODO: DataAndMetadata from_rpc_dict fails for RGB
intensity_calibration = Calibration.from_rpc_dict(d.get("intensity_calibration"))
if "dimensional_calibrations" in d:
Expand All @@ -101,7 +101,7 @@ def rpc_dict(self):
d = dict()
data = self.data
if data is not None:
d["data"] = base64.b64encode(numpy.ndarray.dumps(data)).decode('utf=8')
d["data"] = base64.b64encode(pickle.dumps(data)).decode('utf=8')
if self.intensity_calibration:
d["intensity_calibration"] = self.intensity_calibration.rpc_dict
if self.dimensional_calibrations:
Expand Down

0 comments on commit 83dda92

Please sign in to comment.