As described
in another thread I'm thinking of writing a plugin to reset permissions on files in the auto-add directory so they don't get stuck there for weeks until I manually reset them. (The rights and wrongs of it are discussed extensively in that thread, but I feel like trying it anyway, as an exercise if nothing else.)
The idea is to have a plugin which spins off a background thread when Calibre starts up, which shuts down when Calibre shuts down. I was thinking of something along the following lines:
Code:
class MyPlugin(Plugin):
keepRunning = True
def threadBody():
while keepRunning:
...
def __init__(self):
thread = new Thread(target=threadBody)
thread.start()
Can anyone advise me:
(a) am I going about this in the right way -- that is, will this do what I want?
(b) what are the lifecycle issues I need to deal with (i.e. setting my keepRunning flag to False to shut down the thread in an orderly way; handling plugin reloads or whatever) and how do I deal with them?
(c) is there anything else I should know before I dive in (apart from RTFM, of course)?
I've never written a plugin before, so feel free to tell me I'm a complete idiot!