My backend is written in .NET/C#, I have a requirement that I need to execute python scripts passing context from the .net side of the house. These are queued up in a background task engine called hangfire running as a windows service.
I did a little digging and found IronPython, however, after implementing it failed to support many of the pypi python packages that I need to execute inside my script.
Secondly, I looked at Python.Net which is a embedded interpreter that embeds or extends CPython. CPython can run all the scripts/etc that I needed, however, I found that opening/closing the python interpreter all the time can create quite a few memory leaks and there is always threading constraints there too. See docs for some of the details.
I'm wondering if this interopt and embedding python in .net is even a good idea. I'm wondering if making python its own execution engine using something like celery and marshalling data between the two using something like protobufs would be a better solution? This adds much more complexity and an additional task engine to my stack too.
I was wondering if anyone else had any ideas/feedback/experiences trying to accomplishing something similar? Thanks!
I would argue that pythonnet is your best option:
GIL
with using (Py.GIL()) {}
blocks.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With