Re: [Tutor] One basic question about the Python's PID of Process object.

2011-08-29 Thread Lisi
On Monday 29 August 2011 07:17:51 Han Guanghua wrote:
> 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’”.
>
>  

I'm very much a beginner myself, but I am sure that someone will correct me if 
I am wrong.  Should it not be self.pid rather than self._pid?

Lisi
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] One basic question about the Python's PID of Process object.

2011-08-28 Thread Han Guanghua
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"

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor