[ZODB-Dev] question about connections

Victor Safronovich vsafronovich at naumen.ru
Tue Oct 25 01:31:46 EDT 2005


Hello Tim Peters,

Tuesday, October 25, 2005, 7:50:49 AM, you wrote:

TP> I'm not entirely sure what you're trying to accomplish.  time.sleep(x) is
TP> the _natural_ way to spell "this thread wants to yield to other threads for
TP> at least the next x wall-clock seconds".  If that's what you want to do,
TP> time.sleep(x) is the clearest way to spell it.

TP> In contrast,

TP>     threading.Event().wait(x)

TP> creates an Event that can never be set, waits for it despite that it can
TP> never be set, and sticks a timeout of x on it I guess because it _knows_
TP> it's waiting for an Event that can never get set ;-)

TP> Under the covers, it does the same thing, but more expensively (does a
TP> sequence of time.sleep()s, waking up now and again to check whether the
TP> Event has been set, which never happens, and then finally times out).
   Tim, Thank you for your comment, I switch my code to use time.sleep.
   I find that the threading module is poor for documentation, i only found
   the
class _Semaphore(_Verbose):
    # After Tim Peters' semaphore class, but not quite the same (no maximum)
class _Event(_Verbose):
    # After Tim Peters' event class (without is_posted())
    But i don`t understand exactly that this comments mean.

TP> The code you showed sets the pool size to 15 on the single, specific
TP> *instance* of the DB class exposed by Zope.__init__.py (it's an instance
TP> named "DB" of a class that's also named "DB").  It has no effect on any
TP> other instance of the DB class that may be created by you, Zope, or any
TP> other product you may be using.  There is no way to set the pool size to 15
TP> globally (for _all_ instances of the DB class); you can only set it on one
TP> DB instance at a time.  If you see 15 sometimes and 7 other times, that
TP> means more than one DB instance exists and is begin used.  Sorry, I can't
TP> tell you where or how from what you've said; what's certain is that code
TP> somewhere is using an instance of the DB class other than the Zope.DB
TP> instance.
   I  think  the  one  DB  instance  is  using  by  Zope,  DB  that  created  in
   Zope2.App.startup.startup ( zope 2.8 way )  function,  I`ll  check  the  object
   __builtins__.id  of the DB instance/instances.

TP> I don't know whether this will help you:  you have to try it.  The thing to
TP> try is to replace:
TP>             while self.running:
TP>                 get_transaction().begin()
TP> with:
TP>             while self.running:
TP>                 app._p_jar.sync()
TP> There's no need to do get_transaction().begin() if you're calling sync().
TP> It's OK if you do both (it will just waste some time).
   Thank you, Tim, again. This help me enough.
   
-- 
Best regards,
 Victor Safronovich
 NauMen.NauDoc.SoftwareDeveloper  http://www.naumen.ru



More information about the ZODB-Dev mailing list