I don't know if this works, but try the psutil module, which should work on both Windows and Unix.
import os, psutil ownPid = os.getpid() #This one works in Windows, but os.getuid() does not... ownUid = [p.uid for p in psutil.process_iter() if p.pid == ownPid][0]
source share