Which core am I running on?

psaffrey at googlemail.com psaffrey at googlemail.com
Mon Feb 9 08:53:10 EST 2009


On 9 Feb, 12:24, Gerhard Häring <g... at ghaering.de> wrote:
> http://objectmix.com/python/631346-parallel-python.html
>

Hmm. In fact, this doesn't seem to work for pp. When I run the code
below, it says everything is running on the one core.

import pp
import random
import time
from string import lowercase

ncpus = 3

def timedCharDump(waittime, char):
	time.sleep(waittime)
	mycore = open("/proc/%i/stat" % os.getpid()).read().split()[39]
	print "I'm doing stuff!", mycore, char
	return char

job_server = pp.Server(ncpus, ppservers=())

jobdetails = [ (random.random(), letter) for letter in lowercase ]

jobs = [ job_server.submit(timedCharDump,(jinput1, jinput2), (),
("os", "time",)) for jinput1, jinput2 in jobdetails ]

for job in jobs:
	print job()


Peter



More information about the Python-list mailing list