code: def start_scan(self, scan_id, targets, parallel=1):
          
  
          os.setsid()
          multiscan_proc = []
          logger.info("%s: Scan started.", scan_id)
          target_list = targets
          if target_list is None or not target_list:
              raise OSPDError('Erroneous targets list', 'start_scan')
  
          for index, target in enumerate(target_list):
              while len(multiscan_proc) >= parallel:
                  progress = self.calculate_progress(scan_id)
                  self.set_scan_progress(scan_id, progress)
                  multiscan_proc = self.check_pending_target(scan_id,
                                                             multiscan_proc)
                  time.sleep(1)
  
              #If the scan status is stopped, does not launch anymore target scans
              if self.get_scan_status(scan_id) == ScanStatus.STOPPED:
                  return
  
              logger.info("%s: Host scan started on ports %s.", target[0], target[1])
              scan_process = multiprocessing.Process(target=self.parallel_scan,
                                                     args=(scan_id, target[0]))
              multiscan_proc.append((scan_process, target[0]))
              scan_process.start()
              self.set_scan_status(scan_id, ScanStatus.RUNNING)
  
          # Wait until all single target were scanned
          while multiscan_proc:
              multiscan_proc = self.check_pending_target(scan_id, multiscan_proc)
              if multiscan_proc:
                  progress = self.calculate_progress(scan_id)
                  self.set_scan_progress(scan_id, progress)
              time.sleep(1)
  
          # Only set the scan as finished if the scan was not stopped.
          if self.get_scan_status(scan_id) != ScanStatus.STOPPED:
              self.finish_scan(scan_id)
docs: Handle N parallel scans if 'parallel' is greater than 1.