exxeleron / qPython

interprocess communication between Python and kdb+
http://www.devnet.de
Apache License 2.0
151 stars 90 forks source link

Inbound synchronous calls into python #33

Open vasakt opened 8 years ago

vasakt commented 8 years ago

The documentation does not address how to send replies to inbound synchronous KDB calls. For example, if the python code registers with a KDB server and then receives synchronous requests to perform some function and send a reply back. Sending back a response via a standard async call doesn't seem to work.

vasakt commented 8 years ago

Found that calling QConnection.query(QConnection.MessageType.RESPONSE, responsevalue) works. Perhaps you could add this to documentation for the benefit of other users. Thanks.

maciejlach commented 8 years ago

Could you please provide us with minimal code (kdb+ and python) to reproduce behavior?

vasakt commented 8 years ago

Hi Maciej

As mentioned in the subsequent comment, I managed to work out how to send a synchronous response from qpython using the query method but it would be useful to document as I’m sure I’m not the only one who might want to do this.

On the python side:

from qpython import qconnection

handle = qconnection.QConnection(host = 'localhost', port = 7777)

handle.open()

handle.async('register[]')

message = handle.receive()

handle.query(qconnection.MessageType.RESPONSE, "Some Response")

On the KDB side:

\p 7777

register:{h::.z.w; h"dosomething[]"}

Thanks

Tom

From: Maciej Lach [mailto:notifications@github.com] Sent: Tuesday, 24 November 2015 7:55 PM To: exxeleron/qPython qPython@noreply.github.com Cc: vasakt tom.vasak@agilearchitechs.com Subject: Re: [qPython] Inbound synchronous calls into python (#33)

Could you please provide us with minimal code (kdb+ and python) to reproduce behavior?

— Reply to this email directly or view it on GitHub https://github.com/exxeleron/qPython/issues/33#issuecomment-159199148 . https://github.com/notifications/beacon/AFWWz7wGygitAW5Tr7W1KWlIN0lgF7JZks5pJB2AgaJpZM4GoE_6.gif

maciejlach commented 8 years ago

Thank you for providing the sample. We will try to include it in the documentation.

tfangz888 commented 8 years ago

submit new issue is not allowed. so I past a new issue here. sorry

time is wrong in console example:

In q: q).z.z 2016.06.15T22:49:42.868 q).z.Z 2016.06.16T10:49:47.925 q)

in qpython: Q).z.z <class 'qpython.qtemporal.QTemporal'> 2016-06-16T06:50:16.811+0800 [metadata(qtype=-15)] Q).z.Z <class 'qpython.qtemporal.QTemporal'> 2016-06-16T18:50:21.444+0800 [metadata(qtype=-15)]