I have created a small script in python where I want to execute two function on the same time using multiprocessing. The first function would do a directory recursive search and the second one will display some questions to the user. Although the .txt file is created the question doesn't appear. I have seen this question: Python command line input in a process but as a beginner I did not understand what is the problem and how to solve it. Here's my script:
import os
import thread
import time
from multiprocessing import Process
def writeFiles():
#open a file for writing files in it
f = open("testFile.txt","w")
#do the walk
for root ,dirs,files in os.walk('C:\\Users'):
for dir in dirs:
if dir.startswith('Test'):
for root ,dirs,files in os.walk('C:\\Users\\' + dir +'\Desktop'):
for file in files:
if file.endswith('.txt'):
#include the full path
f.write( os.path.join(root, file + "\n") )
#close the file
f.close()
def ask():
a = raw_input('Your name? ')
if a == 'Tester':
print 'Hello'
else:
print 'Bye'
if __name__ == '__main__':
# create processes
p1 = Process( target = writeFiles)
p2 = Process( target = ask)
p1.start()
p2.start()