0

I'm mainly posting this as I'm not sure if the multiprocessing lib is available for python 3x and if that's not the case, I need something that will allow one python script to send data as cleanly and efficiently as possible to another. They are separate so I cannot call one of them using import.

To explain it more in detail, I have to bots running with the discord.py library and so I cannot run one under the other using a function or class, but I want to pass data between them that way they can communicate without having to write into a file or enter a submission in chat.

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
SoulFanatic
  • 131
  • 1
  • 2
  • 8

1 Answers1

0

What you are looking for is called interprocess communication.

They are gathered together at https://docs.python.org/3/library/ipc.html - you can dig depper into module signal or mmap - which is using memory mapped files which you excluded by choice.


I only ever worked with named pipes - both programs use the same name and communicate over a named pipe:

FIFOs are pipes that can be accessed like regular files. FIFOs exist until they are deleted (for example with os.unlink()). Generally, FIFOs are used as rendezvous between “client” and “server” type processes: the server opens the FIFO for reading, and the client opens it for writing. Note that mkfifo() doesn’t open the FIFO — it just creates the rendezvous point. Availability: Unix.
(cited from above link)

For windows use: win32pipe, win32file and win32api - see Windows named pipes in practice)

An unix example can be found in this answer to that question: Python read named PIPE

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69