Logan Darby
Logan Darby

Reputation: 145

Pass object into process Python

I have a program with an object trm of terminal, and terminal has the function write() which writes a string to a GUI. I am passing this object into a an object of multiprocessing.Process, however when I call the function write() within this process, it doesn't work. Nothing happens. What is going on?

Upvotes: 0

Views: 247

Answers (1)

vribeiro
vribeiro

Reputation: 161

Are you passing the trm object as the target of the multiprocessing.Process? As long as I know, the target should be a callable. In this case, you should be passing trm.write as the target of the process, not trm. If you need to pass arguments to the target, you can pass through the args parameter, which gets a tuple of arguments that will be passed to your target.

Upvotes: 1

Related Questions