Kodi Community Forum

Full Version: Script keeps running
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I have coded a script that pops up a dialog with few options then each option does some long operation actions (moving files, downloading etc. basically updating utility).
For some reason, after the first dialog shows up, more dialogs are getting popped up (like my script is running over and over).
I have tried creating a new window as a mutex for running but that doesn't work either.
What can I do? Is it Kodi bug or what? Why does the script keeps on getting called without any user interaction?
You'll need to share your code otherwise it's impossible to know what the problem is.
Hi,
Here is the related code.
Code:
def main():
    dialog = xbmcgui.Dialog()
    opt_selected = dialog.select(
        "Choose desired action:", ADDON_OPTIONS_STRINGS)

    if opt_selected < 0 or opt_selected > len(ADDON_OPTIONS_STRINGS):
        xbmcgui.Dialog().ok(SCRIPT_DIALOG_TITLE,
                            "You have selected nothing.")
        return

    ADDON_OPTIONS_FUNCTIONS[opt_selected]()

main()
Posting partial code may not help. The problem might be somewhere else in the code.
Is there a reason you are unwilling to post the complete code?
The code is quite big and fortunately I am experienced in python. The problem occurs no matter what the following code is, So I see no reason in posting the whole code here
(2016-01-31, 12:43)Aviram Wrote: [ -> ]The code is quite big and fortunately I am experienced in python. The problem occurs no matter what the following code is, So I see no reason in posting the whole code here

The reason to post the whole code (or at least make it available somewhere) is so that the problem that you currently can't solve can then be solved by someone else for your benefit.

The problem almost certainly lies in your lack of knowledge of how the Kodi plugin framework works (no disrespect intended; Kodi is very idiosyncratic).

I can think of a couple of reasons why code would loop (could be as simple as if the file that the code is in is imported by one of the subsequent function calls, or perhaps kodi thinks it is a folder item but you not populating a virtual folder), but without seeing the whole code it is impossible to say.

Also important is how the script is invoked in the first place, also is it a kodi plugin or a script.