Python IPC (Inter Process Communication)


I’ve been experimenting with IPC (Inter Process Communication) in Python and as a result of this, have created samples that demonstrate how IPC can be implemented.

They make use of the excellent multiprocessing module and have been documented both with comments and a per process logger (to show the interactions between processes).

Added to GitHub. Hopefully if you’ve stumbled on this page, you’ll find them useful :)

Examples include -

  • FIFO (Named Pipe)
  • Pipe
  • RPC (Remote Procedure Call)
  • Shared Memory

Example Output (Fifo)

INFO:process1:Writing 1
INFO:process1:Writing 2
INFO:process1:Writing 3
INFO:process1:Writing 4
INFO:process2:Read: 1
INFO:process1:Writing 5
INFO:process2:Read: 2
INFO:process2:Read: 3
INFO:process1:Writing 6
INFO:process2:Read: 4
INFO:process1:Writing 7
INFO:process2:Read: 5
INFO:process1:Writing 8
INFO:process2:Read: 6
INFO:process1:Writing 9
INFO:process2:Read: 7
INFO:process1:Writing 10
INFO:process2:Read: 8
INFO:process1:Sleeping for 2
INFO:process2:Read: 9
INFO:process2:Read: 10
INFO:process2:Finished process 2
INFO:process1:Finished process 1