Crash in plugin log

I’ve started noticing that i’m getting the following crash in my plugin log file. Anyone know what it could be?



<br />
2011-02-15 21:11:30,446 (-4f967000) :  CRITICAL (core) - Exception in timed thread named '_really_save' (most recent call last):<br />
  File "/Users/IanDBird/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 855, in _start_timed_thread<br />
    f(*args, **kwargs)<br />
  File "/Users/IanDBird/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/datakit.py", line 126, in _really_save<br />
    pickled_dict = self._core.data.pickle.dump(self._dict)<br />
  File "/Users/IanDBird/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/data.py", line 194, in dump<br />
    self._core.host.execute(code)<br />
  File "/Users/IanDBird/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code.py", line 535, in execute<br />
    exec(code) in self.environment<br />
  File "__pickle__", line 1, in <module><br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 1366, in dumps<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 224, in dump<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 649, in save_dict<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 663, in _batch_setitems<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 600, in save_list<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 615, in _batch_appends<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 562, in save_tuple<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 331, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 419, in save_reduce<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 649, in save_dict<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 663, in _batch_setitems<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 306, in save<br />
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy_reg.py", line 69, in _reduce_ex<br />
TypeError: can't pickle _Element objects<br />




Thanks in advance!
Ian

Hey, that usually happens when you’re trying to save something to the Dict that can’t be saved (e.g. lock). What’re you trying to save to the Dict?

It looks like an XML Element object.

I know that the Framework can add custom objects to the Dict, not sure about XML Elements. I have found, though, that Data is a better way to persist, well, data. Dicts are saved on a schedule (let’s say 5 seconds) after something changed. Which means you’re really not persisting the most recent copy of an object. You can use Data to quickly and easily persist and load data. And then you shouldn’t have an issue with what kinds of objects are being saved, either.



The Dict is also prone to some corruption. Data is generally reliable. I now use the Dict as a pointer to my Data objects, but don’t store constantly changing or large amounts of data in the Dict.

The Dict can be saved on-demand by calling Dict.Save(). Saves are normally delayed to prevent multiple writes when changing several objects at once.



XML elements can’t be saved to either the Dict or using the Data API, as they’re not pure Python objects, but objects created using a dynamically loaded C module. Whichever API you use, you’ll need to convert them between XML strings and real element objects if you want to persist them.

I’m not actually using the Dict to persist any data. I actually call Dict.Reset() in the plugin’s Start method. I originally developed the plugin for V1 of the framework and it used python globals. In the conversion, I decided to move these objects from being globals into the Dict. The idea was to use it as a cache (lasting only the lifetime of the application) to store the results of expensive HTTP request/parsing. I didn’t think that I was storing anything complicated in the Dict (mostly lists/strings/integers) but i’ll need to double check. It’s possible that something has slipped in.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.