hopen with timeout

210 views
Skip to first unread message

sudhakar

unread,
Jul 2, 2018, 7:57:53 PM7/2/18
to Kdb+ Personal Developers
hopen(`::5000;10000) works fine when there is a q session with port 5000.
But it gives an error if there is no q session on port 5000.

I was hoping it will wait 10 seconds before trying again. But it fails right away.
Has anyone used hopen with a timeout?

Flying

unread,
Jul 2, 2018, 9:43:55 PM7/2/18
to Kdb+ Personal Developers
This hopen timeout is more for the case when the remote process is not responsive during connection (busy with another query, in debug mode, etc.). When there is no process listening on the target port, hopen fails straightaway. If you do want a hopen-with-retry kind of semantics, it'd better to just write your little wrapper around hopen with a while loop or something similar.

Alex

unread,
Jul 3, 2018, 5:14:06 AM7/3/18
to Kdb+ Personal Developers
This might help: 

{h::@[hopen;(`:host:port:user:pass);0];while[0=h;system"sleep 5";h::@[hopen;(`:host:port:user:pass);0]]}

Regards 
Alex 
Reply all
Reply to author
Forward
0 new messages