Insuring only a single instance of an Addon is running(script format)
#1
I know that when an addon is started form the Addons Window, only a single Instance of an Addon can run(XBMC closes any that may be running in the background). When starting an addon through the RunScript() Built-in, multiple versions can be threaded in XBMC. This causes a problem with my script(as only a single instance should be running) Is there a way to test to see if it is already running or even being able to cancel the running addon??

Thanks in advanced.
Reply
#2
I am interested in the same thing (for the trakt script).
Reply
#3
Should be possible if you listen for app. calls through a socket.
Let's say you design the addon in three main parts. caller, manager, application.

The caller tries to make a socket connection to the manager. If a connection can be established, the manager send a event message the application. If there are no connection the app. is not running and the call module create a new threaded manager for handling the instance reference for future calls.

Code:
Caller:
  - try connect to socket.
    - Connection established?
      - NO:
         -  Create a new manager
      - YES;
         -  Send a token over the socket
   - exit
  
  
Manager:
  * Create new instance of application
  * Create a thread
    * get application reference
    * Create a socket
  ,>* listen for a request token on socket
  '   * On request: pass token to application through reference
  |   * Check token for a shutdown message
  |     * Shutdown true:
  |       * break
  |     * Suhutdown false:
  '-------- Continue listening
  * Exit


Application:
  * Create a thread
  * Create main application
    * Create application loop
      * Do application stuff
      * check for messages from manager
  * exit
Reply
#4
Ninjamawwe Wrote:I am interested in the same thing (for the trakt script).

just set (and check for) a window property at startup.

here's what i do:

PHP Code:
if xbmc.getInfoLabel"Window(10000).Property(MyScriptRunning)" ) == "True":
    
log('script already running')
else:
    
xbmcgui.Window10000 ).setProperty("MyScriptRunning""True")
    
Start() 
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
Or you can go with a simple soultion as Ronie suggests :p
Atleast if you don't need to interact with the application
Reply
#6
(2011-08-07, 03:32)VictorV Wrote: Or you can go with a simple soultion as Ronie suggests :p
Atleast if you don't need to interact with the application

How close DialogProgressBG  from another script?
Reply

Logout Mark Read Team Forum Stats Members Help
Insuring only a single instance of an Addon is running(script format)1