0

I've got a Flask app run with Apache that uses some custom object that's serialized with jsonpickle. When deserializing with jsonpickle.decode(my_json_string), there's nothing happening, meaning the method does not return anything nor does it throw an error. It's as if it just takes infinitely (haven't observed it finishing).

I've tried with a toy object that's just a few KB big, and I monitor hardware usage, and it's not a memory nor CPU problem.

What's more puzzling, using the same code to load the object in the Python console rather than Flask (using the same virtualenv), everything works smoothly, and the object is decoded in a matter of milliseconds.

import jsonpickle

with open("serialized_object.json") as f:
  object_as_json = f.read()  # this works, print(object_as_json) as expected
my_object = jsonpickle.decode(object_as_json)

This is Python 3.6.8, Flask 0.12.2, jsonpickle 1.2, Apache 2.4.

Line 5 in the code snippet above never finishes execution when run in Flask app/Apache. In the normal Python console, all works fine.

I'm afraid I don't know what more info to provide, but any help or pointers are greatly appreciated!

EDIT: I should perhaps add that the serialized object contains a Pytorch Module, but as I said that's really quite small.

UPDATE: I tried using pickle instead and noticed exactly the same behaviour, strangely. I then removed some of the Pytorch components of the object and it all worked fine, so it seems like this is not a jsonpickle/pickle problem at all.

Joko
  • 166
  • 3
  • 17
  • Any chance you could put a debug statement before the call? You could then pause execution to see what's going on. – Joe Bane Jul 16 '19 at 16:47
  • did you check `print(object_as_json)` to see what you get from file ? – furas Jul 16 '19 at 16:48
  • Hi Joe and furas, yes I tried both of that. The json is read correctly and all works fine until line 5. A debug statement before line 5 prints fine, but after that it's just as if it pauses. – Joko Jul 17 '19 at 09:50
  • what's the type of object you're trying to pickle? – abdusco Jul 17 '19 at 11:43
  • Hi abdusco, had just edited the question: it's a custom object that contains a Pytorch module, next to a small number of string and integer attributes, nothing too fancy. I wonder if Pytorch could be causing trouble... – Joko Jul 17 '19 at 11:48

0 Answers0