Leak when run subprocess in python -


when run leak. not sure happening. guess pipe not close or might else happening. in advance guys!

def deactivatemetadatadevice(input_dmd_lun_wwn):     #print('pvremove /dev/mapper/' + input_dmd_lun_wwn)     status_cmd = false     ps = subprocess.popen('/sbin/pvremove /dev/mapper/' + input_dmd_lun_wwn, shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout)     line in iter(ps.stdout.readline, ''):         print line         if re.search('wiped', line):            status_cmd = true         else:            # cleaning metadata , removing lvm if ok return true            status_cmd = false            raise warning('\t\t pv /dev/mapper/'+ input_dmd_lun_wwn +' belongs volume group')      return status_cmd 

getting issue when run code above.

file descriptor 4 (pipe:[323948]) leaked on pvremove invocation. parent pid 15380: python 

the problem return before reading of data in pipe , don't issue wait return code , remove process operating system pid table. think few tweaks (i removed few things thought redundant).

def deactivatemetadatadevice(input_dmd_lun_wwn):     #print('pvremove /dev/mapper/' + input_dmd_lun_wwn)     status_cmd = false     ps = subprocess.popen('/sbin/pvremove /dev/mapper/' + input_dmd_lun_wwn, shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout)     line in ps.stdout:         print line         if 'wiped' in line:            status_cmd = true     ps.wait()     # need handle ps.returncode != 0     if status_cmd false:        # cleaning metadata , removing lvm if ok return true        raise warning('\t\t pv /dev/mapper/'+ input_dmd_lun_wwn +' belongs volume group')     return status_cmd # not needed because using exceptions errors 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -