Question: Use only Python Programming for this question. 6. Alice created a program that does two tasks - one that performs some background task and the

 Use only Python Programming for this question. 6. Alice created a

Use only Python Programming for this question.

6. Alice created a program that does two tasks - one that performs some background task and the other backing up a database. See her code below: 1 import threading, time, random 2 3 4 def background_task(): while True: print("doing background stuff...") time. sleep(0.5) 5 6 7 8 9 def backup_database (copies): for i in range (copies): print("BACKING UP...{i}") time. sleep(1) 10 11 12 13 14 15 16 if_ "_main": copy = random.randint(1, 5) t1 = threading.Thread(target=background_task) t2 = threading.Thread(target=backup_database, args=(copy,)) 17 18 19 t1.start() t2.start Her idea is to get her main task which is backing up database to run until it has backup the specified number of copies. And at the same time, another thread perform some background task while the other is backing up the database. It is intended for the program to terminate when the backup is completed and any background task should be killed as well with the program. However, even when the backup task is completed, the program still keep on running and is displaying "doing background stuff..." like forever. Can you help her fix the code so that her program can terminate when the backup process is completed? *Do NOT modify the functions, background_task and backup_database

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!