Closed maddream-org closed 2 years ago
Hi there,
be careful about your terminology: Multiprocessing does not create threads (i.e. execution contexts inisde of a process that share the same memory), but instead creates multiple operating system-level processes that each have their own memory. To communicate commands across process boundaries, you can use the communication utilities from the multiprocessing
package. In your case, an easy option would be to use a multiprocessing.Queue
. Put 'commands' into the queue on the remote process end, e.g something like queue.put(["play", "/path/to/file"])
, and then have a listener running on a separate thread in the local process that reads commands out of that queue and controls mpv.
Note that multiprocessing.Queue is not the same as queue.Queue.
I want to access MPV's loadfile ("play" allias) from another process:
`import multiprocessing
player = mpv.MPV() player.play("...") //It's work
def AnotherProcess(): player.play("...") //It's not work, but i need it.
multiprocessing.Process(target=AnotherProcess).start() `
How can I do that?