Posts: 6
Joined: Apr 2012
Reputation:
0
2012-09-01, 14:44
Hello guys,
I'm a new video plugin, and the service I'm scrapping needs to receive a heartbeat every 25 minutes. How could I implement this in the most simple way ... Please not that I would like to control the thread which is doing the ping, in order to stop it at any point.
Best,
O.
Posts: 793
Joined: Oct 2010
Reputation:
17
Every 25 minutes 24/7 or just while you're playing videos from there?
Create a second addon as a dependency of your main add on. Your main addon launches the secondary addon at playback start. The secondary runs in a while loop that checks to see that Xbmc is playing a video and that a setting in the main addon is true. When playback is finished, set the setting false. The secondary addon will die on its next loop
Posts: 6
Joined: Apr 2012
Reputation:
0
Thank you for the advice. I was looking for something similar to a cron scheduler and I found something started in the XBMC community. Unfortunately, the project I'm talking about schedules only XBMC tasks, so I cannot use it.
What can I use for the communication between the two plugins ? Just a flagging system through the settings repositories ?
Posts: 793
Joined: Oct 2010
Reputation:
17
If you need to communicate more than just when to run and when to stop, you've got fewer options:
1. Get familiar with threading in python. Kick off a thread that checks an instance variable instead of a setting
2. Use a database to trade information between the two addons. Caveat: sqlite doesn't support multiple simultaneous connections so you'd have to make sure that only one side or the other tries to access the db at a time