Python multiprocessing.Process.__init__() Examples

The following are 30 code examples of multiprocessing.Process.__init__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module multiprocessing.Process , or try the search function .
Example #1
Source File: process.py    From ms_deisotope with Apache License 2.0 6 votes vote down vote up
def __init__(self, ms_file_path, queue, start_scan=None, max_scans=None, end_scan=None,
                 no_more_event=None, ignore_tandem_scans=False, batch_size=1, log_handler=None):
        if log_handler is None:
            log_handler = show_message
        Process.__init__(self)
        self.daemon = True
        self.ms_file_path = ms_file_path
        self.queue = queue
        self.loader = None

        self.start_scan = start_scan
        self.max_scans = max_scans
        self.end_scan = end_scan
        self.ignore_tandem_scans = ignore_tandem_scans
        self.batch_size = batch_size

        self.log_handler = log_handler

        self.no_more_event = no_more_event 
Example #2
Source File: pyscriptexecutor.py    From grinder with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        ip_script_mapping: dict,
        hosts_info: dict,
        workers: int = 100,
        mute: bool = False,
    ):
        """
        Initialize a process manager with a set of scripts, host information and additional flags

        :param ip_script_mapping: mapping ip addresses to run scripts
        :param hosts_info: host information list
        :param workers: number of running processes
        :param mute: bool flag for running scripts in silent mode (w/o output at all)
        """
        freeze_support()
        self.manager = Manager()
        self.results_pool = self.manager.dict({})
        self.ip_script_mapping = ip_script_mapping
        self.hosts_info = hosts_info
        self.workers = workers
        self.mute = mute 
Example #3
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self,camera):
    self.camera = camera
    self.label_shape = 800,600
    self.scale_length = 350
    self.last_reticle_pos = (0,0)
    self.root = tk.Tk()
    self.root.protocol("WM_DELETE_WINDOW",self.stop)
    self.zoom_step = .1
    self.reset_zoom()
    self.img = self.camera.read_image()[1]
    self.on_resize()
    self.convert_img()
    self.create_window()
    self.update_img()
    self.start_histogram()
    self.update_histogram()
    self.refresh_rate = 1/50
    self.low = 0
    self.high = 255
    self.t = time()
    self.t_fps = self.t
    self.go = True
    #self.main() 
Example #4
Source File: nmapprocessmanager.py    From grinder with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        hosts: list,
        ports=DefaultProcessManagerValues.PORTS,
        sudo=DefaultProcessManagerValues.SUDO,
        arguments=DefaultProcessManagerValues.ARGUMENTS,
        workers=DefaultProcessManagerValues.WORKERS,
    ):
        freeze_support()
        self.manager = Manager()
        self.results_pool = self.manager.dict({})
        self.hosts = hosts
        self.workers = workers
        self.arguments = arguments
        self.ports = ports
        self.sudo = sudo 
Example #5
Source File: nmapprocessmanager.py    From grinder with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        queue: JoinableQueue,
        arguments: str,
        ports: str,
        sudo: bool,
        hosts_quantity: int,
        results_pool: dict,
    ):
        Process.__init__(self)
        self.queue = queue
        self.arguments = arguments
        self.ports = ports
        self.sudo = sudo
        self.quantity = hosts_quantity
        self.results_pool = results_pool 
Example #6
Source File: parcalc.py    From Elastic with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, restart=None, ignore_bad_restart_file=False, label=None,
                 atoms=None, calc=None, block=False, **kwargs):
        '''Basic calculator implementation.
        restart: str
            Prefix for restart file.  May contain a directory.  Default
            is None: don't restart.
        ignore_bad_restart_file: bool
            Ignore broken or missing restart file.  By default, it is an
            error if the restart file is missing or broken.
        label: str
            Name used for all files.  May contain a directory.
        atoms: Atoms object
            Optional Atoms object to which the calculator will be
            attached.  When restarting, atoms will get its positions and
            unit-cell updated from file.

        Create a remote execution calculator based on actual ASE calculator 
        calc.
        '''
        logging.debug("Calc: %s Label: %s" % (calc, label))
        Calculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
        logging.debug("Dir: %s Ext: %s" % (self.directory, self.ext))
        self.calc=calc
        self.jobid=None
        self.block=block 
Example #7
Source File: engine.py    From NoXss with MIT License 5 votes vote down vote up
def __init__(self, browser_type, case_list):
            Process.__init__(self)
            self.browser = browser_type
            self.case_list = case_list 
Example #8
Source File: multiproc.py    From CorpusTools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, initval=False):
        self.val = Value('i', initval)
        self.lock = Lock() 
Example #9
Source File: multiproc.py    From CorpusTools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, iterable, queue, stopped):
        Process.__init__(self)
        self.iterable = iterable
        self.queue = queue
        self.stopped = stopped 
Example #10
Source File: multiproc.py    From CorpusTools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, initval=0):
        self.val = Value('i', initval)
        self.lock = Lock() 
Example #11
Source File: multipro.py    From xrt with MIT License 5 votes vote down vote up
def __init__(self, locCard, plots, outPlotQueues, alarmQueue, idLoc):
        Process.__init__(self)
        GenericProcessOrThread.__init__(self, locCard, plots, outPlotQueues,
                                        alarmQueue, idLoc) 
Example #12
Source File: multipro.py    From xrt with MIT License 5 votes vote down vote up
def __init__(self, locCard, plots, outPlotQueues, alarmQueue, idLoc):
        self.status = -1
        if locCard.backend.startswith('shadow'):
            self.runDir = locCard.cwd + os.sep + 'tmp' + str(idLoc)
        self.idN = idLoc
        self.status = 0
        self.plots = plots
        self.outPlotQueues = outPlotQueues
        self.alarmQueue = alarmQueue
        self.card = locCard
        if self.card.backend.startswith('raycing'):
            self.card.beamLine.flow = [] 
Example #13
Source File: SubIxLoad.py    From RENAT with Apache License 2.0 5 votes vote down vote up
def __init__(self,log_name,task_queue, result_queue):
        Process.__init__(self)
        self.task_queue     = task_queue
        self.result_queue   = result_queue
        self.elapsed = None
        self.log_engine = None
        self.repository = None
        self.random = Common.random_name('_tmp%05d','0','99999') 
Example #14
Source File: resultprocess.py    From pypykatz_server with MIT License 5 votes vote down vote up
def __init__(self, resQ, output_dir):
		Process.__init__(self)
		self.resQ = resQ
		self.output_dir = output_dir
		
		if not os.path.exists(self.output_dir):
			try:
				os.makedirs(self.output_dir)
			except Exception as e:
				traceback.print_exc() 
Example #15
Source File: multipro.py    From xrt with MIT License 5 votes vote down vote up
def __init__(self, locCard, plots, outPlotQueues, alarmQueue, idLoc):
        Thread.__init__(self)
        GenericProcessOrThread.__init__(self, locCard, plots, outPlotQueues,
                                        alarmQueue, idLoc) 
Example #16
Source File: engine.py    From NoXss with MIT License 5 votes vote down vote up
def __init__(self, id, browser, url_list):
        Process.__init__(self)
        self.id = id
        self.url_list = url_list
        self.browser = browser 
Example #17
Source File: process.py    From job-web-demo with MIT License 5 votes vote down vote up
def __init__(self, data_queue):
        Process.__init__(self)
        self.data_queue = data_queue 
Example #18
Source File: engine.py    From NoXss with MIT License 5 votes vote down vote up
def __init__(self):
        Process.__init__(self) 
Example #19
Source File: engine.py    From NoXss with MIT License 5 votes vote down vote up
def __init__(self, traffic_obj):
        """
        Do some preprocess work.
        :param traffic_obj:
        """
        self.request, self.response = traffic_obj[0], traffic_obj[1]
        self.param_dict = {}
        self.reflect = [] 
Example #20
Source File: engine.py    From NoXss with MIT License 5 votes vote down vote up
def __init__(self, id, url_list,coroutine):
        Process.__init__(self)
        self.id = id
        self.url_list = url_list
        self.coroutine=coroutine 
Example #21
Source File: train_eval.py    From FaceNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, gpuid, in_queue, out_queue, signal_queue):
        Process.__init__(self, name='ImageProcessor')

        self.gpuid = gpuid
        self.in_queue = in_queue
        self.out_queue = out_queue
        self.signal_queue = signal_queue 
Example #22
Source File: lfw_eval.py    From FaceNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, gpuids, signal_queue):
        self.signal_queue = signal_queue
        manager = mp.Manager()
        self.in_queue = manager.Queue()
        self.out_queue = manager.Queue()
        self._gpuids = gpuids

        self.__init_workers() 
Example #23
Source File: lfw_eval.py    From FaceNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, gpuid, in_queue, out_queue, signal_queue):
        Process.__init__(self, name='ImageProcessor')

        self.gpuid = gpuid
        self.in_queue = in_queue
        self.out_queue = out_queue
        self.signal_queue = signal_queue
        self.detector = dlib.get_frontal_face_detector()
        self.sp = dlib.shape_predictor(predictor_path) 
Example #24
Source File: inference.py    From FaceNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, gpuids, signal_queue):
        self.signal_queue = signal_queue
        self.in_queue = manager.Queue()
        self.out_queue = manager.Queue()
        self._gpuids = gpuids

        self.__init_workers() 
Example #25
Source File: inference.py    From FaceNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, gpuid, in_queue, out_queue, signal_queue):
        Process.__init__(self, name='ImageProcessor')

        self.gpuid = gpuid
        self.in_queue = in_queue
        self.out_queue = out_queue
        self.signal_queue = signal_queue 
Example #26
Source File: BaseMultiProcessEnv.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self, envs):
        GridObjects.__init__(self)
        self.envs = envs
        for env in envs:
            if not isinstance(env, Environment):
                raise MultiEnvException("You provided environment of type \"{}\" which is not supported."
                                        "Please only provide a grid2op.Environment.Environment class."
                                        "".format(type(env)))

        self.nb_env = len(envs)
        max_int = np.iinfo(dt_int).max
        self._remotes, self._work_remotes = zip(*[Pipe() for _ in range(self.nb_env)])

        env_params = [envs[e].get_kwargs(with_backend=False) for e in range(self.nb_env)]
        self._ps = [RemoteEnv(env_params=env_,
                              remote=work_remote,
                              parent_remote=remote,
                              name="{}_subprocess_{}".format(envs[i].name, i),
                              seed=envs[i].space_prng.randint(max_int))
                    for i, (work_remote, remote, env_) in enumerate(zip(self._work_remotes, self._remotes, env_params))]

        for p in self._ps:
            p.daemon = True  # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self._work_remotes:
            remote.close()

        self._waiting = True 
Example #27
Source File: BaseMultiProcessEnv.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self, env_params, remote, parent_remote, seed, name=None):
        Process.__init__(self, group=None, target=None, name=name)
        self.backend = None
        self.env = None
        self.env_params = env_params
        self.remote = remote
        self.parent_remote = parent_remote
        self.seed_used = seed
        self.space_prng = None
        self.fast_forward = 0
        self.all_seeds = [] 
Example #28
Source File: BaseMultiProcessEnv.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self, envs):
        GridObjects.__init__(self)
        self.envs = envs
        for env in envs:
            if not isinstance(env, Environment):
                raise MultiEnvException("You provided environment of type \"{}\" which is not supported."
                                        "Please only provide a grid2op.Environment.Environment class."
                                        "".format(type(env)))

        self.nb_env = len(envs)
        max_int = np.iinfo(dt_int).max
        self._remotes, self._work_remotes = zip(*[Pipe() for _ in range(self.nb_env)])

        env_params = [envs[e].get_kwargs(with_backend=False) for e in range(self.nb_env)]
        self._ps = [RemoteEnv(env_params=env_,
                              remote=work_remote,
                              parent_remote=remote,
                              name="{}_subprocess_{}".format(envs[i].name, i),
                              seed=envs[i].space_prng.randint(max_int))
                    for i, (work_remote, remote, env_) in enumerate(zip(self._work_remotes, self._remotes, env_params))]

        for p in self._ps:
            p.daemon = True  # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self._work_remotes:
            remote.close()

        self._waiting = True 
Example #29
Source File: BaseMultiProcessEnv.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self, env_params, remote, parent_remote, seed, name=None):
        Process.__init__(self, group=None, target=None, name=name)
        self.backend = None
        self.env = None
        self.env_params = env_params
        self.remote = remote
        self.parent_remote = parent_remote
        self.seed_used = seed
        self.space_prng = None
        self.fast_forward = 0
        self.all_seeds = [] 
Example #30
Source File: misc.py    From pyscf with Apache License 2.0 5 votes vote down vote up
def __init__(self, func):
        self.func = func