def process_document_parser(http_resp, processes, hash_string, debug):
 pid = multiprocessing.current_process().pid
 processes[hash_string] = pid
 if debug:
  msg = '[mp_document_parser] PID %s is starting to parse %s'
  args = (pid, http_resp.get_url())
  om.out.debug((msg % args))
 try:
  document_parser = DocumentParser(http_resp)
 except Exception as e:
  if debug:
   msg = '[mp_document_parser] PID %s finished parsing %s with exception: "%s"'
   args = (pid, http_resp.get_url(), e)
   om.out.debug((msg % args))
  raise
 else:
  if debug:
   msg = '[mp_document_parser] PID %s finished parsing %s without any exception'
   args = (pid, http_resp.get_url())
   om.out.debug((msg % args))
 return document_parser

def process_document_parser ( http_resp , processes , hash_string , debug ) : pid = multiprocessing . current_process ( ) . pid processes [ hash_string ] = pid if debug : msg = '[mp_document_parser] PID %s is starting to parse %s' args = ( pid , http_resp . get_url ( ) ) om . out . debug ( ( msg % args ) ) try : document_parser = DocumentParser ( http_resp ) except Exception as e : if debug : msg = '[mp_document_parser] PID %s finished parsing %s with exception: "%s"' args = ( pid , http_resp . get_url ( ) , e ) om . out . debug ( ( msg % args ) ) raise else : if debug : msg = '[mp_document_parser] PID %s finished parsing %s without any exception' args = ( pid , http_resp . get_url ( ) ) om . out . debug ( ( msg % args ) ) return document_parser
simple wrapper to get the current process id and store it in a shared object so we can kill the process if needed .