How to make operator data persistent? My addon needs just one button currently and I'd like it to work as a start/stop button. But on every button press Blender creates a new instance of the corresponding bpy.types.Operator thus losing any connection to already created ones to stop them. What are the ways (if any) to circumvent this behaviour? How to make bpy.types.Panel button work with the same instance of operator?

The addon in question is accelblend, intended to receive accelerometer data and rotate view accordingly. The operator is modular and keeps running in the background just fine. Source: http://bazaar.launchpad.net/~xintx-ua/+junk/accelblend/view/head:/accelblend_receiver.py
There are a few options open to you:


Yes you can keep the operator instance by keeping the operator running, in this case you would need to start a modal operator, then use some action to trigger it (think the knife tool - it stays running and but act's when the mouse is dragged).Note: This is the most direct answer to your question - however its only really useful in specific cases.
Store the settings externally.
Typically when you store settings externally, the operators invoke function will read from these settings when initializing.


In a Python dictionary outside the operator instance (settings will be lost on restarting Blender unless you implement callbacks to write and restore them)
In custom properties (custom Scene properties is often used for this)
In the addons user preferences (not so good for per-blend-file data)
In a text data block (normally not optimal but including for completeness)