简体   繁体   English

C#线程运行python脚本

[英]C# thread running python script

I have several python scripts and would like to run them using .net thread pool, each thread running a python script (I have .net doing lot other stuff for me and towards the end needs to call this python script). 我有几个python脚本,想使用.net线程池运行它们,每个线程运行一个python脚本(我让.net为我做很多其他工作,最终需要调用此python脚本)。 How can I accomplish this? 我该怎么做?

I could start a process for each python script, but was hoping threading would be more efficient way to accomplish this.I am new to threading, any thoughts in right direction will help. 我可以为每个python脚本启动一个过程,但希望线程化是实现此目标的更有效方法。我对线程化是陌生的,任何朝着正确方向的想法都会有所帮助。

Update: just did a some more research that we can use Ironpython to run python script (by doing something like Python.CreateRuntime()) but i am not sure if that would it self create another process. 更新:刚刚进行了更多研究,我们可以使用Ironpython运行python脚本(通过执行类似Python.CreateRuntime()的操作),但是我不确定是否会自行创建另一个进程。

Yes, IronPython can be use for this purpose. 是的,IronPython可以用于此目的。 See http://blogs.msdn.com/b/charlie/archive/2009/10/25/hosting-ironpython-in-ac-4-0-program.aspx for details on running a script from from .Net 有关从.Net运行脚本的详细信息,请参见http://blogs.msdn.com/b/charlie/archive/2009/10/25/hosting-ironpython-in-ac-4-0-program.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM