Quiz 1
Test what you have learnt so far.
We'll cover the following...
We'll cover the following...
Question # 1
Consider the snippet below:
def child_task(str_obj):
print(str_obj.__hash__())
if __name__ == '__main__':
str_obj = "Educative!"
multiprocessing.set_start_method('fork')
print(str_obj.__hash__())
process1 = Process(target=child_task, args=(str_obj,))
process1.start()
process2 = Process(target=child_task, args=(str_obj,))
process2.start()
process1.join()
process2.join()
Technical Quiz
1.
What will be the output of all the print statements?
A.
Exactly the same
B.
All are different
C.
They may be different
1 / 1
Question # 2
Consider the same code from the previous question and assume we change the start method from fork to spawn.
Technical Quiz
1.
Will the output of the print statements be same?
A.
Yes
B.
No
C.
Maybe
1 / 1
Observe that if the start method is changed to forkserver then the id for str_obj variable will be the same for all child ...