I want to use multiprocessing.Value to use a variable in multiple processes, but the syntax is not clear on Python\'s documentation. Can anyone tell me what should I use as
I think the original issue you were having (causing the TypeError
) was because the lock
argument to the multiprocessing.Value
constructor is a keyword-only argument. You need to call multiprocessing.Value("c", temp, lock=False)
in order for it to do what you were wanting to do.
However, I don't think you need to use a Value
object at all. You're passing the keycode as an argument to your other process, and the Value
isn't being used at all. I'd get rid of it completely:
def key(event):
instance = multiprocessing.Process(target=player, args=(event.char,))
instance.start()