<s> from __future__ import print_function , unicode_literals <EOL> import time <EOL> import subprocess <EOL> import traceback <EOL> _PROCESSES = [ ] <EOL> def start_process ( popen_args = None , popen_kargs = None ) : <EOL> if popen_args is None : <EOL> popen_args = ( ) <EOL> if popen_kargs is None : <EOL> popen_kargs = { } <EOL> process = subprocess . Popen ( * popen_args , ** popen_kargs ) <EOL> _PROCESSES . append ( process ) <EOL> return process <EOL> def clean_created ( ) : <EOL> copy = _PROCESSES [ : ] <EOL> for process in copy : <EOL> _PROCESSES . remove ( process ) <EOL> for process in copy : <EOL> if process . poll ( ) is None : <EOL> try : <EOL> process . terminate ( ) <EOL> except : <EOL> traceback . print_exc ( ) <EOL> counter = <NUM_LIT:20> <EOL> while counter > <NUM_LIT:0> and len ( [ p for p in copy if p . poll ( ) is None ] ) > <NUM_LIT:0> : <EOL> counter -= <NUM_LIT:1> <EOL> time . sleep ( <NUM_LIT> ) <EOL> for process in copy : <EOL> if process . poll ( ) is None : <EOL> try : <EOL> process . kill ( ) <EOL> except : <EOL> traceback . print_exc ( ) </s>
