Opened 6 years ago
Closed 6 years ago
#14 closed task (fixed)
limit only one process
| Reported by: | zhangjr | Owned by: | zhangjr |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | component1 | Version: | |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Parent ID: | Parent Tickets: | ||
| Estimated Number of Hours: | 0.0 | Add Hours to Ticket: | 0 |
| Billable?: | yes | Total Hours: | 0 |
Description
def singleton(isStop=False):
pidList=[]
mypid = os.getpid()
myname = os.path.basename(file)
for proc in psutil.process_iter(['pid', 'name']):
try:
if proc.name() == u"python3" or proc.name() == u"python":
if myname in proc.cmdline():
pidList.append(proc.infopid?)
except psutil.AccessDenied?:
print ("error: access denied")
for p in pidList:
if p != mypid:
psutil.Process(p).kill()
if isStop:
psutil.Process(mypid).kill()
Subtickets
Child Tickets
Change History (2)
comment:1 Changed 6 years ago by zhangjr
- Owner changed from somebody to zhangjr
- Status changed from new to accepted
comment:2 Changed 6 years ago by zhangjr
- Resolution set to fixed
- Status changed from accepted to closed
Note: See
TracTickets for help on using
tickets.
