Kodi Community Forum
Q: Load list in "background" - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Q: Load list in "background" (/showthread.php?tid=144160)



Q: Load list in "background" - derolf - 2012-11-01

Hi,

at the moment, I load the whole directory at once, which might take a while.

is it possible to fill the directory incrementally, without blocking the GUI? (Kind of background thread that fills the directory)

I guess that I can launch a pyhton thread to do the background work, so can I notify the GUI to reload the directory from my addon?

dero


RE: Q: Load list in "background" - sphere - 2012-11-01

I guess you are talking about a add-on of type "plugin", correct?
In plugins you can't add listitems asynchronous.

There are design-workarounds like using a pagination or using parent-folders for separate initials.

You could also show your code - maybe we can find a solution.


RE: Q: Load list in "background" - derolf - 2012-11-01

Yes, I am talking about a video plugin.

I build the list from many REST calls.

I guess I could spawn a thread to do this and then fill the directory from the current state of the background fetcher's results.

Is it possible to trigger a directory reload?

dero


RE: Q: Load list in "background" - sphere - 2012-11-01

In theory yes, you could do a reload with
Code:
xbmc.executebuiltin("Container.Refresh()")
But your plugin should be started by the directory request and should exit itself after calling:
Code:
xbmcplugin.endOfDirectory(HANDLE)



RE: Q: Load list in "background" - derolf - 2012-11-01

Quote:But your plugin should be started by the directory request and should exit itself after calling:

What happens if there was still a thread running?


RE: Q: Load list in "background" - Bstrdsmkr - 2012-11-01

The thread will run until completion. You need to design your plugin with this in mind so that you don't deadlock Xbmc when it tries to exit but has to wait for a thread to finish. A common method is to have the child thread check Xbmc.abortrequested() before doing anything and exit if it's true.


RE: Q: Load list in "background" - derolf - 2012-11-01

Okay, so basically it's supported what I want... THANKS!