embedPy icon indicating copy to clipboard operation
embedPy copied to clipboard

Add support for asyncio

Open abalkin opened this issue 8 years ago • 3 comments

It should be possible to implement an asyncio event loop based on kdb+ sd1/sd0. Once such an event loop is available, it should be straightforward to implement asynchronous calls from q to Python.

abalkin avatar Nov 12 '17 23:11 abalkin

so if a message came in on .z.ps, how might code look from handling that message to returning a response - using asyncio?

jfakx avatar Nov 18 '17 13:11 jfakx

You can see some simple examples in the Python Manual. Ideally something like

p)async def hello_world(x):'
    await asyncio.sleep(10)
    print("Hello World!")
.z.ps:.p.callable .p.pyeval"hello_world"

would result in "Hello World!" printed on the server console 10 seconds after each client message, but will not block the client.

abalkin avatar Nov 18 '17 19:11 abalkin

@jhanna-kx @jfakx - Is there any way to expose the sd1/sd0 handlers like in C so that python can run threaded work and push results back into the Q session?

mittonsimon avatar Oct 07 '19 11:10 mittonsimon