[ZODB-Dev] Deferred notifing from one thread to another.

Tim Peters tim at zope.com
Fri Dec 9 11:18:26 EST 2005


[Victor Safronovich]
> ...
> Of course i may write time.sleep( SLEEP_CONSTANT ) before
> app._p_jar.sync(), but is this a good solution?

I can't make time to understand your problem (sorry!), but I can make time
to tell you that a bare time.sleep() is almost never a good solution to
thread problems.  time.sleep() in a _loop_ can be reliable, provided you can
write code to recognize when what you're waiting for has happened; this
approach is called "polling".

    while what I'm waiting for hasn't happened:
        time.sleep(WHATEVER)

For example, when you change a persistent object, its ._p_changed attribute
gets set to a true value.  When the change gets committed, ._p_changed is
reset to a false value.  So _perhaps_ (I'm not sure -- being sure would
require understanding all of your problem) you could poll waiting for some
specific object's _p_changed to become false.



More information about the ZODB-Dev mailing list