Using invokeAsynchronous to run intensive query in background and showing data in a power table

I have a need here where data from a remote database is fetched through an API, and that data is then displayed in a power table. while doing so, the script executes for a long time. Lets say 30 seconds, during that time the client freezes over, i understand the reason why, hence to work around that I’m trying to use invokeAsynchronous and invokeLater functions, but still the issue remains.

Anyway, It would really help if someone can support me with this.

Edit: This was sorted out, hence the script was removed. If anyone requires help/ the scripting for this reply back in this thread.

Please edit your post to place triple backquotes (these: ```) on a line above and again on a line below your script so it formats properly.

When you call system.util.invokeAsyncrhonous(tagfetch), and have a parameter param, you really need to set it to something in the function call as you can’t do it in the system.util.invokeAsynchronous call, so something like def tagfetch(param = someOtherDefinedVariable):

Also, when you try

for x in response I don’t see where response was defined? So currently it looks like that would do nothing.

Also, please appropriately indent your code, python lives and dies by indents so reading what you have its hard to tell whats inside the function and whats inside the main extension function.

As posted, the incorrect indentation of control structures and the missing data flow make your script indecipherable. Please post the entire real script, anonymizing where needed instead of cutting.

I have posted the entire script as used, with proper formatting. hope it helps.

As I said earlier, that was just an edited version of the code. you could refer the one that I recently updated. My point being, the function works properly, I just need it to get executed asynchronously, in a parallel thread.

@pturmel I have figured it out. Thanks for the help anyway.