title: How can I change multithreading with multiprocessing in the code (Python)
body: <p>I wrote a program which implements caesar-cipher with threads and queues with python. I would like to change all the threading work with multiprocessing in my code and I have no idea how to do it. I would appreciate if you could explain where &amp; how to start the implementation. Here is the code:</p>
  
  <pre><code>import threading
  import Queue
  import sys
  import string
  
  lock = threading.Lock()
  def do_work(in_queue, out_queue, shift):
      while True:
          lock.acquire()
          item = in_queue.get()
          result = caesar(item, shift)
          out_queue.put(result)
          in_queue.task_done()
          lock.release()
  def caesar(plaintext, shift):
      plaintext = plaintext.upper()
      alphabet = string.ascii_uppercase
      shifted_alphabet = alphabet[shift:] + alphabet[:shift]
      table = string.maketrans(alphabet, shifted_alphabet)
      return plaintext.translate(table)
  
  if __name__ == "__main__":
      if len(sys.argv) != 4:
          print("Duzgun giriniz: '&lt;filename&gt;.py s n l'")
          sys.exit(0)
      else:
          s = int(sys.argv[1])
          n = int(sys.argv[2])
          l = int(sys.argv[3])
  
      work = Queue.Queue()
      results = Queue.Queue()
      myfile=open('metin.txt','r')
      text_data=myfile.read() # &lt;=== here load file
      index=0
  
      for i in xrange(n):
          t = threading.Thread(target=do_work, args=(work, results, s))
          t.daemon = True
          t.start()
  
      for i in range(0, len(text_data), l):
          work.put(text_data[index:index + l])
          index += l
  
      work.join()
  
      index=0
      output_file=open("crypted"+ "_"+ str(s)+"_"+str(n)+"_"+str(l)+".txt", "w")
      for i in range(0, len(text_data), l):
          output_file.write(results.get())
          index += l
      sys.exit()
  </code></pre>