[Tutor] One basic question about the Python's PID of Process object.
Han Guanghua
guanghua.han at huawei.com
Mon Aug 29 08:17:51 CEST 2011
Hello,
1. When I tried to run the following code (belonging to one Python
program), for the dynamically created object of CUSTOMER as Process type,
the printed PID as the following is always the same.
Why?
2. Second question: When I changed the os.getpid() to os.getppid() or self.
_pid, the Python’s interpreter generates some error message like
“Customer object has no attribute ‘_pid’”.
Thanks for your help!
Partly code for the CUSTOMER object:
class Customer(Process):
def buyBaguette(self,cusType,bakery):
tIn=now()
print "PID is %d"%(os.getpid())
yield get,self,bakery.stock,r.choice(buy[cusType])
waits[cusType].append(now()-tIn)
def __del__(self):
print "distroy the customer"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110829/4deaec0b/attachment.html>
More information about the Tutor
mailing list