English 中文(简体)
改用新写的字典
原标题:Terminate a python script from another python script

我拿着长篇长篇的字典,我想用另一个字典来结束。 理想的情况是,我所期待的是某种方式,即为第一稿确定一个过程,并且能够看到它是否从第二版开始运行。 此外,我希望能够结束这一漫长的进程。

是否存在任何冷却的捷径来做到这一点?

此外,Im还在Windows环境中工作。

我最近在这里找到了一个替代答案:。 检查假装是否运行

最佳回答

你们可以通过自己的项目信息数据库(Process Identifier)

import os
os.getpid()

并杀害“团结”进程

import os, signal
os.kill(5383, signal.SIGKILL)

to kill in Windows use

import subprocess as s
def killProcess(pid):
    s.Popen( taskkill /F /PID {0} .format(pid), shell=True)

您可以将笔记单发送到其他节目,或者你可以查询程序清单,查找其他文字的名称并用上述文字加以杀害。

我希望能帮助你们。

问题回答

页: 1

import subprocess as sp

extProc = sp.Popen([ python , myPyScript.py ]) # runs myPyScript.py 

status = sp.Popen.poll(extProc) # status should be  None 

sp.Popen.terminate(extProc) # closes the process

status = sp.Popen.poll(extProc) # status should now be something other than  None  ( 1  in my testing)

次级处理。 开放式开始使用外部字典,相当于在ole或终点站打字的字典。

次级处理状况。 如果程序仍在进行,则开放。 如果地位被以另一种方式关闭,则不清楚。

这在窗口11和PyQt5下为我工作:

subprocess.Popen( python3 MySecondApp.py )
Popen.terminate(app)

页: 1 (打字机,运行)和<代码> My SecondApp.py (称为文字)





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签