process cannot access the file because it is being used by other process
Thomas Jollans
thomas at jollans.com
Mon Jun 21 16:18:22 EDT 2010
On 06/21/2010 12:18 PM, shanti bhushan wrote:
> [snip]
>
> i used below code
>
> import subprocess
> import time
> def invoke_server1():
> proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
> \372\pythonweb\mongoose-2.8.exe -root D:\New1\"')
>
>
> invoke_server1()
>
>
> time.sleep(10)
> proc.kill()
This cannot work, since proc is not a global variable, it's local to
invoke_server1. You could do something like this instead:
def invoke_server1()
return subprocess.Popen([r'D:\372\pythonweb\mongoose-2.8.exe',
'-root', r'D:\New1\"])
server1_proc = invoke_server1()
time.sleep(10)
server1_proc.kill()
Are you running the code from a command prompt ? It should have printed
a nice and helpful NameError. Had you read that error message, it should
have been easy to figure out that there's something wrong with your
variable scopes.
-- Thomas
More information about the Python-list
mailing list