Long running database queries

Hi All,
Im using Ignition 8.1.35 with Vision.
We have made a small search tool to search for events in a special table in SQL Server that gets data from the alarm journal.
We have had some help making the right indexes and searching is generally fast.
From the GUI we call runPrepQuery using the example from the documentation system.util.invokeAsynchronous:

def longProcess(rootContainer = event.source.parent):
   import system
   # Do something here with the database that takes a long time
   results = ...( call runPrepQuery )
   # Now we'll send our results back to the UI
   def sendBack(results = results, rootContainer = rootContainer):
      rootContainer.resultsProperty = results
   system.util.invokeLater(sendBack)
    
system.util.invokeAsynchronous(longProcess)

I have seen some examples of users making queries that run longer than the 1 minute timeout on the Gateway
and the query ends up hanging in the Gateway and I need to cancel the query in the Gateway.
Can you somehow cancel the query before it times out in the Gateway?

I've looked at the transaction parameter (tx) for the runPrepQuery, but that put's a lock on my table and that is it not the way to go.

I would check out this to start.

To my knowledge there is no mechanism for canceling a query from Ignition. The best you can probably do is to catch the timeout exception and then react appropriately.