Hard
Lock Simulation
Write a context manager
Lock that prints acquired and released and refuses (raises RuntimeError) if already held. Try to use the same lock nested; catch the RuntimeError and print busy. The input says whether to nest (yes/no).Input
yes or no.
Output
Lines.
Sample 1
Input
yes
Output
acquired working busy released
Sample 2
Input
no
Output
acquired working released
Output appears here