Always be careful with int() incase any of the values have a leading
zero - check the documentation for int() carefully.
 
Cheers,
 
Tim Delaney

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Robert Rawlins - Think Blue
Sent: Monday, 24 September 2007 5:10 PM
To: 'Robert Rawlins - Think Blue'; python-list@python.org
Subject: RE: Almost There - os.kill()



Woops,

 

Spoke too soon, just wrapped them in int() and it works a charm :-D

 

Rob

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
rg] On Behalf Of Robert Rawlins - Think Blue
Sent: 24 September 2007 12:23
To: python-list@python.org
Subject: Almost There - os.kill()

 

Hello Guys,

 

Finally got around to sitting down to tidy up this script this morning
but I'm having a small syntax problem with os.kill() to kill a process
on my system. Here is the code:

 

def killApplication():

 

       pid = file('/var/lock/MyApplication.lock').read().strip()

       

       logging.info('Killing Application Process: %s' % pid)

 

       os.kill(pid, 15)

 

       logging.info('Application %s Killed' % pid)

 

As you can see if rips the PID from the lock file, which works fine as I
get log data which says 'Killing Application Process: 3079' exactly as I
would expect it too. However when I run this script I get the following
error:

 

Traceback (most recent call last):

  File "/pblue/new/Alive.py", line 50, in ?

    main()

  File "/pblue/new/Alive.py", line 47, in main

    doCheck()

  File "/pblue/new/Alive.py", line 43, in doCheck

    killApplication()

  File "/pblue/new/Alive.py", line 28, in killApplication

    os.kill(pid, 15)

TypeError: an integer is required

 

Which would suggest its passing those arguments in as the wrong data
types to the kill command. What is the best way to convert these?

 

Thanks guys,

 

Rob

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to