cancel
Showing results for 
Search instead for 
Did you mean: 

k() blocks even with negative handle

gyorokpeter
New Contributor
I have an application that sends messages to a q process using k() with a negative handle. I would expect this call to not block, but very rarely it does and both the application and the q process become unresponsive (the communication is bidirectional but uses async messages only).
Why does this happen and how could I debug it?

KDB version is 3.6 2018.05.17 on Windows 10.
2 REPLIES 2

charlie
New Contributor II
New Contributor II
Hi Peter,

although it's deeply buried on code.kx, we do document that this blocks
negative handle here indicates the msg type to be sent; unlike invoking from q, using e.g. neg[h]x, it doesn't actually affect whether it would block or not. The c-api for clients doesn't use non-blocking socket calls.

Hence, I think you'd either need to run the comms in an own thread, or increase the socket buffer sizes sufficiently so a call to send does not fill the buffers.

hth,
Charlie

Flying
New Contributor III
There is a difference between C/C#/Java/Python API vs native q.

In q, neg[h]x will perform the async query as you desired.

But in other languages, there are separate calls for sync and async messages being sent to a q process. Please refer to the manual for the respective language API for the details.