Unfortunately, I don't know a method to do that.
The reason is that the main thread may be in the middle of a query resolution when a dynamic thread changes a clause. It's like changing a python program while it is running : scary.
Now, if you can make sure that no queries are currently run in the main thread when you change statements, you have a better chance to have it work. But no garantee though.
Thank you for your message anyway.
PC
See e.g. http://stackoverflow.com/questions/10525185/python-threading-how-do-i-lock-a-thread
Pierre C.