I wanted to do a stack inquiry before I do a deep dive tomorrow and start trying out every option under the sun. We have an application that we've embedded python inside with PyBind 11. In the current implementation application events are triggering an xml-rpc call to a remote server and its working fine.
We are looking, however, to extend this functionality by either adding a websocket server, connecting into Kafka or MQ or some other sort of functionality - allowing for both incoming and outgoing messages.
Where I'm running into some design questions is as I understand I have 1 interpreter which means I likely (by default) have 1 thread available.
I'm trying to figure out what approach gives me the following:
- Application events in C++ will be allowed to call into the Python interpreter and fire off events
- Events received by the python interpreter will call back into C++
I'm pretty sure this is easy to setup one way or the other but I'm getting confused how to handle both things at once.
I can setup a websocket server easily enough - but if my server is actively running
start_server = websockets.serve(counter, "localhost", 6789)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
Am I still able going to be able to make additional calls into the interpreter or is Python going to be locked up?
In summary:
When using embedded Python - if I have an actively running process (say listening for messages on a websocket) am I still able to make calls into the Python interpreter to do additional things - or am I blocked?