I have a long running process which runs a command line application on PC. This command line application processes files and writes a log file into the directory it is reading from. This code is the portion which runs the application, i can run up to 4 processes at a time with threading:
command = "C:\\progra~1\\itms\\iTMSTransporter -m verify -f D:\\TEMP -u username -p password -o D:\\TEMP\\LOGFILE.txt -s provider -v eXtreme"
if slotNumber == 1:
self.process1 = Popen(command, shell=True, stdin=PIPE)
elif slotNumber == 2:
self.process2 = Popen(command, shell=True, stdin=PIPE)
elif slotNumber == 3:
self.process3 = Popen(command, shell=True, stdin=PIPE)
elif slotNumber == 4:
self.process4 = Popen(command, shell=True, stdin=PIPE)
After it has completed it runs this section:
if slotNumber == 1:
wx.CallAfter(self.process1.kill)
elif slotNumber == 2:
wx.CallAfter(self.process2.kill)
elif slotNumber == 3:
wx.CallAfter(self.process3.kill)
elif slotNumber == 4:
wx.CallAfter(self.process4.kill)
The only problem is that it is not releasing the directory and log file, If I try to move or rename the directory it says something is still using it. Looking at Windows Task Manager (screen grab below) it clearly shows lot of cmd.exe's and conhost.exe's. If I manually 'end process' for all these in Task Manager then the directory and log file is now relased and I can delete, move, rename, etc. If I run this application manually via command line from a command window when it completes the directory and log file is released straight away. Anyone have any idea why they are not being released in my Python code?