SectorUnkown / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Multiprocessing not working #722

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I can't get multiprocessing to work in PyScripter.  I have described two 
examples below.

Example 1 - multiprocessing.Process

What steps will reproduce the problem?
1. Try to run the code example below from a script (obtained from a tutorial at 
http://www.doughellmann.com/PyMOTW/multiprocessing/basics.html).

import multiprocessing

def worker():
    """worker function"""
    print 'Worker'
    return

if __name__ == '__main__':
    jobs = []
    for i in range(5):
        p = multiprocessing.Process(target=worker)
        jobs.append(p)
        p.start()

What is the expected output? What do you see instead?
The expected output is:
Worker
Worker
Worker
Worker
Worker
However, when I run the script, I get no output at all.  It doesn't crash.  It 
just does nothing.

What version of the product are you using? On what operating system?
PyScripter version 2.5.3.0 x86 with python 32-bit 2.7.2 on Windows 7 64-bit

Please provide any additional information below.
If I try to run this same script from IDLE, it does the same thing, producing 
no output but not crashing.  If I run it from a DOS command line, it DOES work.

---------------------------

Example 2 - multiprocessing.Pool

What steps will reproduce the problem?
1. Try to run the code example below from a script (obtained from the python 
doc at http://docs.python.org/2/library/multiprocessing.html).

from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    pool = Pool(processes=4)              # start 4 worker processes
    result = pool.apply_async(f, [10])    # evaluate "f(10)" asynchronously
    print result.get(timeout=1)           # prints "100" unless your computer is *very* slow
    print pool.map(f, range(10))          # prints "[0, 1, 4,..., 81]"

What is the expected output? What do you see instead?
The expected output is:
100
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

However, when I run the script from PyScripter, I get a TimeoutError from 
pool.py:
Traceback (most recent call last):
  File "<string>", line 254, in run_nodebug
  File "<module3>", line 9, in <module>
  File "C:\Python27\ArcGIS10.1\Lib\multiprocessing\pool.py", line 518, in get
    raise TimeoutError
multiprocessing.TimeoutError

What version of the product are you using? On what operating system?
PyScripter version 2.5.3.0 x86 with python 32-bit 2.7.2 on Windows 7 64-bit

Please provide any additional information below.
If I try to run this same script from IDLE, it works correctly.  If I run it 
from a DOS command line, it also works correctly.

Original issue reported on code.google.com by melindam...@gmail.com on 28 Jan 2013 at 6:42

GoogleCodeExporter commented 9 years ago
I am have the same problem in PyScripter (2.5.3.0 x86) on a Windows 7 (64bit) 
machine runing the 32 bit version of 2.7.2 Python. I'm using this simple 
example:

import multiprocessing
import os

def test():
    print "hello"

def main():
    pool = multiprocessing.Pool()
    pool.apply(test)
    pool.apply(test)
    pool.apply(test)
    pool.close()
    pool.join()

if __name__ == '__main__':
    main()

Original comment by hornb...@googlemail.com on 6 Feb 2013 at 5:11

GoogleCodeExporter commented 9 years ago
Issue 681 has been merged into this issue.

Original comment by pyscripter on 23 Mar 2015 at 2:54

GoogleCodeExporter commented 9 years ago
Issue 777 has been merged into this issue.

Original comment by pyscripter on 23 Mar 2015 at 2:54