6

im running my function with multiprocessing implementation

def assign_task(self, module, command):
        logging.debug("Assigning task for {0}".format(command._get_module_id()))
        if self.queue is None:
            self.queue = JoinableQueue()
        if self.processes is None:
            self.processes = [Process(target=self.do_execute) for i in range(self.max_process)]
            for process in self.processes:
                process.daemon = True
                process.start()

        logging.debug("Queuing message {0}".format(command._get_module_id()))
        self.queue.put((module, command))

    def do_execute(self):
        # the code

but getting this error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\muhammad.aqshol\AppData\Local\Programs\Python\Python38\lib\multiprocessing\spawn.py", line 107, in spawn_main
    new_handle = reduction.duplicate(pipe_handle,
  File "C:\Users\muhammad.aqshol\AppData\Local\Programs\Python\Python38\lib\multiprocessing\reduction.py", line 79, in duplicate
    return _winapi.DuplicateHandle(
OSError: [WinError 6] The handle is invalid

Am i wrong on the implementation or something missing?

  • Does this answer your question? [Python running as Windows Service: OSError: \[WinError 6\] The handle is invalid](https://stackoverflow.com/questions/40108816/python-running-as-windows-service-oserror-winerror-6-the-handle-is-invalid) – Gaëtan GR Jan 20 '21 at 09:21
  • i got the problem, it's because Inter-Process Communication doesn't work between class. – Alifian Adexe Jan 28 '21 at 08:04
  • 1
    Would you expand on that @AlifianAdexe ? – Pedro Braz Mar 07 '22 at 12:29

0 Answers0