Commit Graph

17 Commits

Author SHA1 Message Date
Joris Vink ace8c4e80c Add asynchronous pgsql query support to python.
This commit adds the ability to use python "await" to suspend
execution of your page handler until the query sent to postgresql
has returned a result.

This is built upon the existing asynchrous query framework Kore had.

With this you can now write stuff like:

async def page(req):
	result = await req.pgsql("db", "SELECT name FROM table");
	req.response(200, json.dumps(result).encode("utf-8"))

The above code will fire off a query and suspend itself so Kore can
take care of business as usual until the query is successful at which
point Kore will jump back into the handler and resume.

This does not use threading, it's purely based on Python's excellent
coroutines and generators and Kore its built-in pgsql support.
2017-02-06 11:42:53 +01:00
Joris Vink 6578fc6589 expose http_file interface to python. 2017-02-01 21:23:56 +01:00
Joris Vink 3d8e0dabc0 expose kore_server_bind() and fatal() to python 2017-02-01 17:12:52 +01:00
Joris Vink 30666618f8 expose kore_websocket_send() to python. 2017-01-30 22:00:03 +01:00
Joris Vink 6bfba49ba5 cleanup data if required. 2017-01-30 21:50:36 +01:00
Joris Vink f78e8f2fd2 allow None as source for kore.websocket_broadcast.
This allows kore.websocket_broadcast() to be used to relay the
messages back to all clients rather then all except the sender.
2017-01-30 21:48:58 +01:00
Joris Vink 6a43dd529c export WEBSOCKET_OP_TEXT and WEBSOCKET_OP_BINARY. 2017-01-30 21:02:58 +01:00
Joris Vink 7bc8bb42e2 implement kore_websockat_broadcast. 2017-01-30 20:30:42 +01:00
Joris Vink 7510834968 initial fudging to add websockets to python 2017-01-29 22:57:34 +01:00
Joris Vink c06ecf1c70 Teach single binaries about SIGHUP.
Make sure kore_onload() and kore_preload() can be called
either in native or python runtime.
2017-01-26 13:26:55 +01:00
Joris Vink dcb5fd842f Expose get/post params via req.argument for python. 2017-01-26 12:01:28 +01:00
Joris Vink 1db3cd96d8 allow reloading of python modules on SIGHUP. 2017-01-26 11:13:09 +01:00
Joris Vink 21f9c29f31 style + move pyhttp_dealloc() into !KORE_NO_HTTP. 2017-01-25 22:33:39 +01:00
Joris Vink 9976022a47 let python use kore backed memory allocators. 2017-01-25 22:07:58 +01:00
Joris Vink 620cc231dc validators now work in python. 2017-01-25 21:17:12 +01:00
Joris Vink 7c74a0824b push all integers exported to python in a struct. 2017-01-25 20:56:57 +01:00
Joris Vink bbcdec82fc Add initial python support.
Based on work done by Stanislav Yudin.
2017-01-24 20:18:12 +01:00