I'm working at an unzipper application, and i want to use multiple processes to unzip a number of files from a directory, and i want to have a screen to know about every process and what is it unzipping I'm really new to python programming and I'm new to multiprocessing also
When I'm complining this script, I want to see the status of every process but instead the files just get unzipped and nothing is printed to the screen, until the script has finished unzipping and it ends. Can someone please explain why there is no print on the screen?
import os, zipfile
from multiprocessing import Process
from unicurses import*
import time
dir_name = 'E:\zips'
extension = ".zip"
processes = 3
os.chdir(dir_name)
def unzipper(item,files,poz,no_proc):
if(item.endswith(extension)):
move(no_proc*2,5)
addstr(f"#{no_proc} -> working on {item}...\n")
getch()
file_name = os.path.abspath(item)
zip_ref = zipfile.ZipFile(file_name)
zip_ref.extractall(dir_name)
zip_ref.close()
move(no_proc*2,5)
addstr(f"#{no_proc} finised processing {item}.\n")
if(poz-processes>=0):
item=files.pop(poz-processes)
unzipper(item, files,poz-processes,no_proc)
else:
os.kill(os.getpid())
if __name__ == '__main__':
stdscr=initscr()
print(os.getpid())
procs = []
i=0
list = os.listdir(dir_name)
files=[]
for i in range(0,len(list)):
if(list[i].endswith(extension)):
files.append(list[i])
for no_proc in range(0,processes):
move((no_proc+1)*2,5)
addstr(f"#{no_proc} -> ")
for no_proc in range(0,processes):
if(files!=[]):
item=files.pop()
proc = Process(target=unzipper, args=(item,files,len(files),no_proc+1))
procs.append(proc)
proc.start()
for proc in procs:
proc.join()