Kore.io python support
In recent days Kore finally got python support merged in. It was an interesting experiment. I’ve learned a bit more about CPython API. And now I am much more confident in embedding python and scripting runtime in general into C apps.
My experimental code didn’t make it directly into the kore codebase because I was essentially monkey patching each internal callback with
switch to call into python. This approach could not be used to cover all of the Kore internals and this would make python support not as useful as it can be. So Joris Vink the original author of the Kore worked on a generic callback functions and implemented structures
kore_module_functions to delegate the whole range of possible callbacks to a runtime implementation. Then he ported and reimplemented most of the python logic I’ve done in my branch.
The API had changed a bit compared to what I’ve exposed but at the same time is much more robust and less error prone. Joris also integrated memory allocator from Kore and error handling.
The API exposed to a python code currently is a direct mimic of what Kore’s C API has to offer. I’d like to improve that part and make it more pythonistic and probably focus on these areas:
Let python code export classes instead of function to handle HTTP requests. The interface should be as close to something existing as possible. Probably
tornado.RequestHandleris a good candidate for interface donation.
Try to integrate WSGI interface for callbacks, so that Kore could potentially call into Django and others.
There is no http states yet. Also there is no PostgreSQL async API access from python.
Potentially I am going to build some kind of a service with python-in-kore to get a better feel for it.