01-08-2023 09:50 PM
Hello,
I have the following minimum example working example using multiprocessing:
from multiprocessing import Pool
files_list = [('bla', 1, 3, 7), ('spam', 12, 4, 8), ('eggs', 17, 1, 3)]
def f(t):
print('Hello from child process', flush = True)
name, a, b, c = t
return (name, a + b + c)
def main():
pool = Pool(processes=3) # set the processes max number 3
result = pool.map(f, files_list)
pool.close()
pool.join()
print('end')
print(result)
if __name__ == "__main__":
main()
However, I cannot get anything from the child process to print. The aim is use the text for debugging purposes in the future. Any idea why this does not work or if there are any alternative solution to this? Thank you.
01-09-2023 02:27 PM
Hi, Do you receive any error when you say it is not working?
01-10-2023 01:58 AM
No errors are generated. The code executes successfully, but there the print statement for "Hello from child process" does not work.
01-01-2025 05:09 PM
did you ever figure this out? is it because of map? I'm having the same problem..
01-01-2025 10:56 PM
nm (discovered queue)
Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!
Sign Up Now