[英]Execute Python Script from Django
I am trying to execute a python script from a webpage through a Django view. 我正在尝试通过Django视图从网页执行python脚本。 Other questions related to a known script from within the Django project directory.
其他与Django项目目录中的已知脚本有关的问题。 I need to be able to execute a script anywhere on the system given the file path.
给定文件路径,我需要能够在系统上的任何位置执行脚本。 Eventually, multiple scripts will be run in parallel using Celery or a similar method.
最终,将使用Celery或类似方法并行运行多个脚本。 Should I be using some permutation of popen or sub-processing?
我应该使用popen或子处理的某种置换吗?
I suggest using Celery. 我建议使用芹菜。
subprocess
, multiprocessing
, and threading
all are powerful tools, but are in general hard to get working. subprocess
, multiprocessing
和threading
都是强大的工具,但是通常很难使用。 They're more useful if you already have a working system, are running at the limit of the hardware, and don't mind spending a good deal of effort to get lower latency or parallel processing or higher throughput. 如果您已经有一个操作系统,并且在硬件的限制下运行,并且不介意花费大量精力来获得更低的延迟或并行处理或更高的吞吐量,那么它们将更加有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.