I'm running some code on both a Windows 7 pc and a Windows 10 laptop:
def project(filename):
**Do Something Here**
if __name__ == '__main__':
pool = Pool(processes=4)
results = [pool.apply_async(project, args=(filename,)) for filename in filenamelist]
output = [p.get() for p in results]
print output
Both computers are dual core/4 threads, so they should both be fine running 4 processes. The problem I have is that when I run the code on Windows 10 I get 4 python processes running, but they use 0% of the cpu and they will not output anything, unlike the Windows 7 pc which will run at full usage on all 4 threads and work perfectly.
The code works fine on the Windows 10 laptop if I don't use multiprocessing, so the problem must be related to that. Does multiprocessing with Python not work in Windows 10 yet? I am running Python 2.7 on both machines by the way.
[Edit]: Windows 7 pc processor is an i5-650, Windows 10 laptop processor is an i3-2370M
[Update]: I reverted the laptop back to Windows 8.1 and the exact same code runs as intended, this is definitely a Windows 10 issue.
[Edit]: The method I'm using to generate the filenamelist
is as follows, however this works fine on Windows 7.
def get_unfinished_files(indir, outdir):
filenamelist = []
for filename in os.listdir(indir):
if filename not in os.listdir(outdir) and filename.endswith('.png'):
filenamelist.append(filename)
return filenamelist
Had similar issue. As I found, it was just a bug in python in my case: https://bugs.python.org/issue35797
It occurs when using multiprocessing through venv.
Bugfix is released in Python 3.7.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With