Thanks for the response Gnowm.
Lua is forgiving if you don't use semi colons

It's actually not good because nearly every other language uses them, and after a few hours of being lazy with Lua I end up missing them when I go back to other projects.
I did work this out in the end, but not with the thread manager, which is probably not fit for purpose in this case. I wound up using qglobals to store a condition, and a heartbeat timer to check for the condition and act accordingly.