Showing results for 
Search instead for 
Did you mean: 

Timeout on a sync call

New Contributor
How do I put a timeout on the following sync call ?


The other approach is doing an async call and putting a timeout on the callback. This is something I am not looking for.


New Contributor
For a sync call you can specify a timeout for a single query using a format like `::[(":host:port";timeout);query], an example would be:


This is available since V4.0 2020.03.09. If you wanted a more permanent solution you could use either of the -T flag when starting up the q process or the \T command from within a q session followed by the timeout specification you want. However this timeout will hold true for all things executed in the session, not just sync calls.

See the following pages for more information:  

Hope this helps, 

Thanks Matthew.

"....all things executed in the session, not just sync calls....."

Does this mean any call in for the same session could introduce a timeout (unknowingly) for ALL the other calls for the same session too ?

Not a one-size-fits-all issue.. why do you need a timeout on the client in this case?

There's timeouts for opening a handle and for running a query.
hopen(`::4000;3000) = timeout on opening the connection.

The \T works on the incoming calls, i.e. the 0 handle. "All" is a strong term here, I think you'll find exceptions.

You can (ab)use this by running something on the 0-handle:
No interrupt:
q)system"T 1";do[10000000;sqrt 2];

q)system"T 1";0({do[10000000;sqrt 2]};`)
  [1]  {do[10000000;sqrt 2]}