Find the output of the following Python code and choose the correct answer from the given options.
import multiprocessing
def enr(conn, msgs):
for msg in msgs:
conn.send(msg)
print("{}".format(msg))
conn.close()
def cer(conn):
while 1:
msg = conn.recv()
if msg == "Hi":
break
print("{}".format(msg))
if __name__ == "__main__":
msgs = ["hello", "hey", "hru?", "Hi"]
parent_conn, child_conn = multiprocessing.Pipe()
p1 = multiprocessing.Process(target=enr, args=(parent_conn,msgs))
p2 = multiprocessing.Process(target=cer, args=(child_conn,))
p1.start()
p2.start()
p1.join()
p2.join()
Correct Answer:
hello
hey
hru?
Hi
hello
hey
Hru?
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More Python MCQ Questions