On Nov 24, 4:59 pm, Jon McAlister <[EMAIL PROTECTED]> wrote: > Correct, we don't provide pid or hostname but os.urandom() will yield > a secure random seed, and every runtime process is uniquely seeded, so > you don't need to worry about any two distinct runtime processes ever > generating the same random numbers.
>From http://docs.python.org/library/os.html#os.urandom os.urandom(n) Return a string of n random bytes suitable for cryptographic use. I'm pretty sure that I'll get dups if I call os.urandom(1), or even os.urandom(3), enough times in different processes. (For os.urandom (1), I'm guaranteed a dup by the 256th call and should get a dup before 20 tries; os.urandom(3) should yield dups before 4500 tries.) So, how many bytes do I need to request to get a reasonable guarantee of uniqueness? And, wouldn't it be better to simply provide a function that guarantees uniqueness without involving the datastore? It doesn't even have to return the same string each time it's called within a given sandbox instance's lifetime. As I wrote above, such a function can be provided that doesn't reveal anything about google's infrastructure (which might be why os.getpid() and functions that reveal machine specific info are unavailable). > > If you don't feel like random numbers give you enough of a guarantee > for your app, then you should use the datastore. > > On Nov 23, 3:46 am, yejun <[EMAIL PROTECTED]> wrote: > > > > > There's no currently available method to identify process and machine. > > Your best bet is random id generated during module initialization. > > > On Nov 22, 9:46 pm, Andy Freeman <[EMAIL PROTECTED]> wrote: > > > > > os.getpid isn't available > > > > Thanks. > > > > > nor unique across processes. > > > > Huh? During the life of a process A on a machine B, no other process > > > on B will have the same process id as A. > > > > Two different processes on a given machine may have the same id if > > > their lifetimes are disjoint and two processes on different machines > > > may have the same process id at the same time, but the latter is just > > > why some sort of machine identifier is important. > > > > On Nov 22, 5:43 pm, yejun <[EMAIL PROTECTED]> wrote: > > > > > UUID should be ok, which use system urandom as seed by default. > > > > os.getpid isn't available nor unique across processes. > > > > > On Nov 22, 8:07 pm, "David Symonds" <[EMAIL PROTECTED]> wrote: > > > > > > On Sun, Nov 23, 2008 at 8:50 AM, Andy Freeman <[EMAIL PROTECTED]> > > > > > wrote: > > > > > >> > Suppose that I want to atomically create an entity group with two > > > > > >> > nodes, one the parent of the other. > > > > > >> But *why* exactly do you want to do this? > > > > > > > Because I want "a set of one or more entities that can be > > > > > > manipulated > > > > > > in a single transaction. Entity group relationships tell App Engine > > > > > > to > > > > > > store several entities in the same part of the distributed network. > > > > > > A > > > > > > transaction sets up datastore operations for an entity group, and > > > > > > all > > > > > > of the operations are applied as a group, or not at all if the > > > > > > transaction fails." > > > > > > Yes, I understand transactions and entity groups. Why do you need to > > > > > create an entity group *atomically*? > > > > > > > The fact that GAE uses many machines and concurrently is why the > > > > > > full > > > > > > hostname, IP, or MAC address or some other machine identifier is > > > > > > useful in creating a unique identifier on GAE. (If my application > > > > > > always ran on the same machine, the process id and time would be > > > > > > sufficient.) > > > > > > If you create a new entity, it will automatically be assigned a unique > > > > > key at the datastore level. What's wrong with just using that? > > > > > > Dave.- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
