It seems that starting a multiprocessing.Process()
does not make my code work the way it should. See code below:
from multiprocessing import Process
from sys import exit
class Game():
def __init__(self):
self.cmd = ''
self.balance = 1000
def load_cmd(self):
if self.cmd == 'quit':
# quit game
exit()
if self.cmd == 'balance':
print('Total balance:', self.balance)
def start(self):
while True:
try:
self.cmd = input('?> ')
self.load_cmd()
print('\n')
except EOFError:
self.cmd = 'quit'
if __name__ == '__main__':
# load game
game = Game()
Process(target = game.start).start()
Instead of waiting for an input (while showing the ?>
prompt), the script just keeps printing ?>
without skipping lines. It is impossible to type anything. I tried running the function directly, without starting a process, and everything worked perfectly. Why is this happening?