[Pythonmac-SIG] Replacement for getpid() in macpython?

Peter Ahlstrom ooklathemok@toriyamaworld.com
Sat, 29 Mar 2003 01:18:25 -0500


Hi there,

I just barely got macpython and am trying to get a particular popular 
python program to work in mac os 9. If I modify two lines, things go 
okay, but I'm looking for a better solution.

the lines are

from os import getpid, path, makedirs

and

myid = (chr(0) * 12) + sha(repr(time()) + ' ' + 
str(getpid())).digest()[-8:]

running as-is gives a "cannot import name" (or whatever the exact error 
is) on getpid. Removal of reference to getpid lets the program work 
fine. It's there to help make a unique identifier for the program 
instance when communicating with a remote server. Is there something 
else I can add there which is supported importing from os on classic 
mac os, giving a comparable process identifier, or should I just expect 
time() to do a good enough job?

Peter