Bridging state across a plugin restart

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Perry The Cynic
Posts: 857
Joined: Mon Apr 07, 2008 9:46 pm

Bridging state across a plugin restart

Post by Perry The Cynic »

I have a plugin with expensive state. When it gets restarted (or perhaps crashes :-), I want to save and then restore that state. This is not persistent data - if we don't restart immediately, it should be ditched and reconstructed. How do I go about this? I can easily make a Dict with all the data, but where do I stuff it, and how do I retrieve it?

Cheers
-- perry
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Bridging state across a plugin restart

Post by matt (support) »

I'm not quite sure I understand. It sounds like you do want it to be persistent data, unless the time interval between the stop/crash and next start is > N. In that case you'll want to store the dict in the pluginProps along with a timestamp so you can know if the data should be used or dumped on next launch. Alternatively you can always create/manage your own cache file I suppose.
Image
Perry The Cynic
Posts: 857
Joined: Mon Apr 07, 2008 9:46 pm

Re: Bridging state across a plugin restart

Post by Perry The Cynic »

Of course I could use the PluginProps and a timestamp. But those get written to a preference file, and I just feel a bit dirty using a persistent store for what amounts to transient data. I was hoping to find some corner of Indigo's memory to stash that data. (Indigo's device state gets wiped across a plugin restart, right?)

Cheers
-- perry
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Bridging state across a plugin restart

Post by matt (support) »

There isn't any plugin API access to an Indigo Server runtime dict where plugins can stash semi-persistent (or semi-transient, I guess, if you are a glass-half-empty pessimist) data.

States are maintained, but they can only hold atomic values (no dicts/lists) and they also show up in the trigger/conditional/control page UI. And they might get saved to the database file before the plugin can clear the data. Since the data isn't really a plugin preference (and it might be large?), I'd recommend just writing it to a temp file.
Image
Perry The Cynic
Posts: 857
Joined: Mon Apr 07, 2008 9:46 pm

Re: Bridging state across a plugin restart

Post by Perry The Cynic »

I'd recommend just writing it to a temp file
I'll do that.

Cheers
-- perry
Locked

Return to “Extending Indigo with Plugins and Python”