.NET/C# Interop to Python -
my backend written in .net/c#, have requirement need execute python scripts passing context .net side of house. these queued in background task engine called hangfire running windows service.
i did little digging , found ironpython, however, after implementing failed support many of pypi python packages need execute inside script.
secondly, looked @ python.net embedded interpreter embeds or extends cpython. cpython can run scripts/etc needed, however, found opening/closing python interpreter time can create quite few memory leaks , there threading constraints there too. see docs of details.
i'm wondering if interopt , embedding python in .net idea. i'm wondering if making python own execution engine using celery , marshalling data between 2 using protobufs better solution? adds more complexity , additional task engine stack too.
i wondering if else had ideas/feedback/experiences trying accomplishing similar? thanks!
i argue pythonnet best option:
- embedded python interpreter not same python sub-interpreter. sub-interpreter used less, while cpython has been embedded in major applications. memory leaks should unlikely due pythonnet taking care of you.
- the embedded interpreter not have shutdown between calls - in fact can expensive, can keep persistent long application alive.
- threading issues can avoided if enclose code requiring
gil
using (py.gil()) {}
blocks. - the added benefit of debugging cpython/.net code in mixed-mode using ptvs.
Comments
Post a Comment