Seite 1 von 1

Multiprocessing unter Windows 7

Verfasst: Freitag 6. Mai 2011, 15:35
von darktrym
Ich habe eine Frage bzgl. Multiprocessing. Bei mir funktioniert das erstes Beispiel weder unter Python 2.7.1 noch 3.2 auf einem Windows 7 Rechner. Gibt's evtl noch etwas zu beachten?

Folgendes Verhalten hab' ich:
Es gibt keinerlei Ausgabe und auch keine Terminierung. Dafür aber eine stetig wachsende Anzahl von pythonw-Prozessen bis der Rechner unbedienbar ist. :twisted:

Re: Multiprocessing unter Windows 7

Verfasst: Freitag 6. Mai 2011, 15:48
von b.esser-wisser
Welches 'erste Beispiel'? Etwa das, bei dem dransteht:
docs.python.org hat geschrieben:Functionality within this package requires that the __main__ module be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.Pool examples will not work in the interactive interpreter.
- das kann also gar nicht funktionieren.

So funktioniert's (macht aber nicht sinnvolles):

Code: Alles auswählen

from multiprocessing import Pool

def f(x):
    return x*x
if __name__ == "__main__":
    p = Pool(5)
    p.map(f, [1,2,3])