How do I put a timeout on the following sync call ?
h:hopen `:192.168.12.15:5001
@[h;`func;{0N!x}]
The other approach is doing an async call and putting a timeout on the callback. This is something I am not looking for.
Thanks.
How do I put a timeout on the following sync call ?
h:hopen `:192.168.12.15:5001
@[h;`func;{0N!x}]
The other approach is doing an async call and putting a timeout on the callback. This is something I am not looking for.
Thanks.
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:
`::[(“:localhost:5000:username:password”;5000);“2+3”]
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:
https://code.kx.com/q/ref/hopen/
https://stackoverflow.com/questions/23010704/how-to-set-maximum-execution-time-for-kdb-query
Hope this helps,
Matthew
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)
Interrupt:
q)system"T 1";0({do[10000000;sqrt 2]};`)
'stop
[1] {do[10000000;sqrt 2]}
^