I am not able to get to a my function by calling pool.map(func, iterable) syntax. My iterable is nothing but list of numbers on each line (no other comma seprated values like :
LINE01AA1
LINE02AA1
LINE03AA1
LINE04AA1
LINE01AB1
LINE02AB1
LINE03AB1
The code gives an error which is like Error which is thrown : raise self._value TypeError: cannot concatenate 'str' and 'int' objects code is pasted below :
if __name__ == "__main__":
# print ID of current process
print("ID of process running main program: {}".format(os.getpid()))
# print name of main thread
print("Main thread name: {}".format('Main'))
#Start Time
start = time.clock();
q = Queue()
filename = 'test.csv'#load file
load_file(filename)
print("Total Lines Loaded : " + str(len(my_var)))
p = Pool(2)
p.map(getData, my_var)
p.close()
p.join()end = time.clock();
print "The time was {}".format(end - start)
def load_file(filename):
with open(filename, 'rU') as datafile:
for line in datafile:
my_var.append(line.strip())
def getData(number):
print(number)
proc_name = current_process().name
proc = os.getpid()
print("Process:" + proc_name + " PID: " + proc + "Data : " + number)
#set Data
data['r1[]'] = number[:6]
data['r2'] = number[6:]
#print data
response = requests.post('https://somewebsite/post.php', headers=headers, data=data, proxies=proxies)
print response.text