__author__ = 'dev'

import subprocess


class SubprocessDict:

    def __init__(self):
        self.__process_dict = {}

    def clear_dict(self):

        for entry_process in self.__process_dict.values():
            entry_process.terminate()

        self.__process_dict.clear()

    def add_process(self, args, **kwargs):
        new_process = subprocess.Popen(args, **kwargs)
        self.__process_dict[new_process.pid] = new_process

    def get_process_dict(self):
        return self.__process_dict