-í
Û„?c       s  d  k  Z  d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d k	 l
 Z
 d k l Z d k l Z d k l Z d e f d „  ƒ  YZ e e  d ƒ o% e  i f Z d e  i e  i f Z n e  i f Z d e  i f Z d	 e i f d
 „  ƒ  YZ d f  d „  ƒ  YZ d  S(   N(   s   ReadOnlyError(   s   log(   s   trigger(   s   ManagedConnections   ConnectionManagerc      sz   t  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z	 d
 d „ Z
 d „  Z d „  Z d „  Z RS(   s   Keeps a connection up over timei   i´   c    s†   |  i | ƒ |  _ | |  _ | |  _ | |  _ t i t i	 ƒ  ƒ |  _
 t |  _ d |  _ t |  _ t |  _ d |  _ t i |  i ƒ d  S(   Ni    (   s   selfs   _parse_addrss   addrss   addrlists   clients   tmins   tmaxs	   threadings	   Conditions   Locks   conds   Nones
   connections   closeds   threads   triggers	   thr_asyncs   ThreadedAsyncs   register_loop_callbacks	   set_async(   s   selfs   addrss   clients   tmins   tmax(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   __init__" s    								c    s   d |  i i |  i f Sd  S(   Ns   <%s for %s>(   s   selfs	   __class__s   __name__s   addrlist(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   __repr__1 s    c    s’   |  i | ƒ } | t j	 o | | f g Snb g  } xT | D]L } |  i | ƒ } | t j o t d t | ƒ ‚ n | i	 | | f ƒ q: W| Sd  S(   Ns   unknown address in list: %s(
   s   selfs   _guess_types   addrss	   addr_types   Nones   addrlists   addrs
   ValueErrors   reprs   append(   s   selfs   addrss   addrlists   addrs	   addr_type(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   _parse_addrs4 s     c    sr   t  | t i ƒ o t i Sn t | ƒ d j o+ t  | d t i ƒ o t  | d t i ƒ o t i Sn t	 Sd  S(   Ni   i    i   (
   s
   isinstances   addrs   typess
   StringTypes   sockets   AF_UNIXs   lens   IntTypes   AF_INETs   None(   s   selfs   addr(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   _guess_typeI s
    Ac    sõ   d |  _ |  i i ƒ  z |  i } t |  _ |  i } Wd |  i i	 ƒ  X| t j	 oI t
 d ƒ | i ƒ  | i d ƒ | i ƒ  o t
 d d t i ƒn n | t j	 o | i ƒ  n |  i t j	 o |  i i ƒ  t |  _ n t i |  i ƒ d S(   s6   Prevent ConnectionManager from opening new connectionsi   Ns'   CM.close(): stopping and joining threadi   s(   CM.close(): self.thread.join() timed outs   level(   s   selfs   closeds   conds   acquires   threads   ts   Nones
   connections   conns   releases   logs   stops   joins   isAlives   zLOGs   WARNINGs   closes   triggers   ThreadedAsyncs   remove_loop_callbacks	   set_async(   s   selfs   ts   conn(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   closeU s,     			 

c    s_   t  d t | ƒ d t i ƒ|  i o |  i t j o# t  d ƒ t ƒ  |  _ d |  _	 n d  S(   Ns   CM.set_async(%s)s   levels   CM.set_async(): first calli   (
   s   logs   reprs   maps   zLOGs   DEBUGs   selfs   closeds   triggers   Nones	   thr_async(   s   selfs   map(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys	   set_asyncn s
    
c    s¨   |  i ƒ  |  i i ƒ  z |  i } |  i } Wd |  i i ƒ  X| t	 j	 o
 | t	 j oB | i
 } | i ƒ  |  i i ƒ  z |  i } Wd |  i i ƒ  Xn | t	 j	 Sd S(   s§  Attempt a connection to the server without blocking too long.

        There isn't a crisp definition for too long.  When a
        ClientStorage is created, it attempts to connect to the
        server.  If the server isn't immediately available, it can
        operate from the cache.  This method will start the background
        connection thread and wait a little while to see if it
        finishes quickly.
        N(   s   selfs   connects   conds   acquires   threads   ts
   connections   conns   releases   Nones   one_attempts   events   wait(   s   selfs   ts   conns   event(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   attempt_connect s"    	 

	 	
 i    c    s   |  i i ƒ  zÓ |  i t j	 o d  Sn |  i } | t j oP t d ƒ t |  |  i	 |  i
 |  i |  i ƒ |  _ } | i d ƒ | i ƒ  n | oJ xC |  i t j o2 |  i i d ƒ |  i t j o t d ƒ n q˜ Wn Wd  |  i i ƒ  X| o n d  S(   Ns$   CM.connect(): starting ConnectThreadi   i   s$   CM.connect(sync=1): still waiting...(   s   selfs   conds   acquires
   connections   Nones   threads   ts   logs   ConnectThreads   clients   addrlists   tmins   tmaxs	   setDaemons   starts   syncs   waits   release(   s   selfs   syncs   t(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   connect¥ s,    	
  c    s^   t  d | ƒ |  i i ƒ  z. | |  _ | o t |  _ n |  i i	 ƒ  Wd  |  i i
 ƒ  Xd  S(   Ns   CM.connect_done(preferred=%s)(   s   logs	   preferreds   selfs   conds   acquires   conns
   connections   Nones   threads	   notifyAlls   release(   s   selfs   conns	   preferred(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   connect_done¼ s    	 c    sŠ   |  i i ƒ  zB | |  i j	 o t d d t i ƒd  Sn t d ƒ t |  _ Wd  |  i i	 ƒ  X|  i
 i ƒ  |  i o |  i ƒ  n d  S(   Ns   CM.close_conn() non-currents   levels   CM.close_conn()(   s   selfs   conds   acquires   conns
   connections   logs   zLOGs   BLATHERs   Nones   releases   clients   notifyDisconnecteds   closeds   connect(   s   selfs   conn(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys
   close_connÈ s    
 c    s3   |  i i ƒ  z |  i t j	 SWd  |  i i ƒ  Xd  S(   N(   s   selfs   conds   acquires
   connections   Nones   release(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   is_connectedØ s
     (   s   __name__s
   __module__s   __doc__s   __init__s   __repr__s   _parse_addrss   _guess_types   closes	   set_asyncs   attempt_connects   connects   connect_dones
   close_conns   is_connected(    (    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   ConnectionManager s    						$		s   WSAEWOULDBLOCKi    s   ConnectThreadc      sY   t  Z d  Z e i i Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z RS(   só  Thread that tries to connect to server given one or more addresses.

    The thread is passed a ConnectionManager and the manager's client
    as arguments.  It calls testConnection() on the client when a
    socket connects; that should return 1 or 0 indicating whether this
    is a preferred or a fallback connection.  It may also raise an
    exception, in which case the connection is abandoned.

    The thread will continue to run, attempting connections, until a
    preferred connection is seen and successfully handed over to the
    manager and client.

    As soon as testConnection() finds a preferred connection, or after
    all sockets have been tried and at least one fallback connection
    has been seen, notifyConnected(connection) is called on the client
    and connect_done() on the manager.  If this was a preferred
    connection, the thread then exits; otherwise, it keeps trying
    until it gets a preferred connection, and then reconnects the
    client using that connection.

    c    s]   |  i d d | ƒ | |  _ | |  _ | |  _ | |  _ | |  _ d |  _ t i	 ƒ  |  _
 d  S(   Ns   names   Connect(%s)i    (   s   selfs   _ConnectThread__super_inits   addrlists   mgrs   clients   tmins   tmaxs   stoppeds	   threadings   Events   one_attempt(   s   selfs   mgrs   clients   addrlists   tmins   tmax(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   __init__s    						c    s   d |  _ d  S(   Ni   (   s   selfs   stopped(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   stops    c    sÓ   |  i } d } d } x£ |  i o— |  i | ƒ } |  i i ƒ  o |  i i	 ƒ  d } n | d j o Pn t
 i | ƒ |  i i ƒ  o t d d t i ƒn t | d |  i ƒ } q Wt d |  i ƒ  ƒ d  S(   Ni    i   iK   s/   CT: still trying to replace fallback connections   leveli   s   CT: exiting thread: %s(   s   selfs   tmins   delays   successs   attempt_timeouts   stoppeds   try_connectings   one_attempts   isSets   sets   times   sleeps   mgrs   is_connecteds   logs   zLOGs   INFOs   mins   tmaxs   getName(   s   selfs   delays   successs   attempt_timeout(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   runs"    	 
c    s  t  d t |  i ƒ ƒ t i ƒ  | } |  i ƒ  } x, | i	 ƒ  D] } | i d j o d Sn q@ Wzˆ t i ƒ  | j o d Sn |  i | | ƒ } | t j	 o | Sn t i ƒ  | j o d Sn |  i | | ƒ } | t j	 o | Sn Wd x | i	 ƒ  D] } | i ƒ  qú W~ Xd Sd S(   s  Try connecting to all self.addrlist addresses.

        Return 1 if a preferred connection was found; 0 if no
        connection was found; and -1 if a fallback connection was
        found.

        If no connection is found within timeout seconds, return 0.
        s'   CT: attempting to connect on %d socketss   notifiedi   i    N(   s   logs   lens   selfs   addrlists   times   timeouts   deadlines   _create_wrapperss   wrapperss   keyss   wraps   states   _connect_wrapperss   rs   Nones   _fallback_wrapperss   close(   s   selfs   timeouts   wrapperss   rs   deadlines   wrap(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   try_connecting0s4        c    s­   h  } xœ |  i D]‘ \ } } t | | |  i |  i ƒ } | i	 ƒ  | i
 d j o2 x | i ƒ  D] } | i ƒ  q^ Wh  | | <Sn | i
 d j o | | | <n q W| Sd  S(   Ns   notifieds   closed(   s   wrapperss   selfs   addrlists   domains   addrs   ConnectWrappers   mgrs   clients   wraps   connect_procedures   states   keyss   ws   close(   s   selfs   wrapperss   domains   ws   wraps   addr(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   _create_wrappersRs    
 
 c 
   sá  xÚ| oÒ|  i o) x | i ƒ  D] } | i ƒ  q! Wd Sn g  i } | i ƒ  D]$ } | i d j o | | ƒ n qQ ~ } | o Pn t
 i
 ƒ  | j o Pn yK t i g  | | d ƒ \ } } }	 t d t t t | | |	 f ƒ ƒ ƒ Wn8 t i j
 o) } t d t | ƒ d t i ƒq n Xx6 |	 D]. } t d t | i ƒ ƒ | | =| i ƒ  q0Wxs | D]k } | i ƒ  | i d j o0 | | =x | i ƒ  D] } | i ƒ  qWd	 Sn | i d
 j o | | =n qiWq Wd  S(   Ni    s
   connectingf1.0s   CT: select() %d, %d, %ds   CT: select failed; msg=%ss   levels   CT: closing troubled socket %ss   notifiedi   s   closed(   s   wrapperss   selfs   stoppeds   keyss   wraps   closes   appends   _[1]s   states
   connectings   times   deadlines   selects   rs   ws   xs   logs   tuples   maps   lens   errors   msgs   strs   zLOGs   WARNINGs   addrs   connect_procedure(
   s   selfs   wrapperss   deadlines   _[1]s   msgs   rs
   connectings   ws   wraps   x(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   _connect_wrappers`sJ     
 '!*  
 c    sŠ   xƒ | i ƒ  D]u } |  i i ƒ  o | i ƒ  nK | i ƒ  | i d j o0 | | =x | i ƒ  D] } | i ƒ  q_ Wd Sn | | =q Wd  S(   Ns   notifiediÿÿÿÿ(	   s   wrapperss   keyss   wraps   selfs   mgrs   is_connecteds   closes   notify_clients   state(   s   selfs   wrapperss   deadlines   wrap(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   _fallback_wrappersˆs      
  (   s   __name__s
   __module__s   __doc__s	   threadings   Threads   __init__s   _ConnectThread__super_inits   stops   runs   try_connectings   _create_wrapperss   _connect_wrapperss   _fallback_wrappers(    (    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   ConnectThreadï s    				"		(s   ConnectWrapperc      sD   t  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sØ   An object that handles the connection procedure for one socket.

    This is a little state machine with states:
        closed
        opened
        connecting
        connected
        tested
        notified
    c    sÛ   | |  _  | |  _ | |  _ | |  _ d |  _ t |  _ t |  _ d |  _	 t
 d t | ƒ ƒ y t i | t i ƒ |  _ WnC t i j
 o4 } t
 d | | f d t i ƒ|  i ƒ  d Sn X|  i i d ƒ d |  _ d S(   s/   Store arguments and create non-blocking socket.s   closedi    s   CW: attempt to connect to %ss&   CW: can't create socket, domain=%s: %ss   levelNs   opened(   s   domains   selfs   addrs   mgrs   clients   states   Nones   socks   conns	   preferreds   logs   reprs   sockets   SOCK_STREAMs   errors   errs   zLOGs   ERRORs   closes   setblocking(   s   selfs   domains   addrs   mgrs   clients   err(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   __init__¨s&     								
	c    sM  |  i d d f j oy |  i i |  i ƒ } WnF t i j
 o7 } t	 d |  i | f d t
 i ƒ|  i ƒ  d Sn Xt	 d |  i t i i | ƒ p
 t | ƒ f ƒ | t j o d |  _ d Sn | t j oK t	 d |  i t i i | ƒ p
 t | ƒ f d t
 i ƒ|  i ƒ  d Sn d |  _ n |  i d j o |  i ƒ  n d S(	   s0   Call sock.connect_ex(addr) and interpret result.s   openeds
   connectings   CW: connect_ex(%r) failed: %ss   levelNs   CW: connect_ex(%s) returned %ss   CW: error connecting to %s: %ss	   connected(   s   selfs   states   socks
   connect_exs   addrs   errs   sockets   errors   msgs   logs   zLOGs   ERRORs   closes   errnos	   errorcodes   gets   strs   _CONNECT_IN_PROGRESSs   _CONNECT_OKs   WARNINGs   test_connection(   s   selfs   errs   msg(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   connect_procedure¾s*     
	0	,
c    sé   t  |  i |  i |  i |  i ƒ |  _ t |  _ y% |  i i |  i ƒ |  _	 d |  _
 Wnx t j
 o, t d t |  i ƒ ƒ |  i ƒ  d SnB t d t |  i ƒ d t i d t i ƒ  ƒ|  i ƒ  d Sn X|  i	 o |  i ƒ  n d S(   s´   Establish and test a connection at the zrpc level.

        Call the client's testConnection(), giving the client a chance
        to do app-level check of the connection.
        s   testeds(   CW: ReadOnlyError in testConnection (%s)Ns    CW: error in testConnection (%s)s   levels   error(   s   ManagedConnections   selfs   socks   addrs   clients   mgrs   conns   Nones   testConnections	   preferreds   states   ReadOnlyErrors   logs   reprs   closes   zLOGs   ERRORs   syss   exc_infos   notify_client(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   test_connection×s$     	


c    s   y |  i i |  i ƒ WnA t d t |  i ƒ d t i d t	 i
 ƒ  ƒ|  i ƒ  d Sn Xd |  _ |  i i |  i |  i ƒ d S(   s0  Call the client's notifyConnected().

        If this succeeds, call the manager's connect_done().

        If the client is already connected, we assume it's a fallback
        connection, and the new connection must be a preferred
        connection.  The client will close the old connection.
        s!   CW: error in notifyConnected (%s)s   levels   errorNs   notified(   s   selfs   clients   notifyConnecteds   conns   logs   reprs   addrs   zLOGs   ERRORs   syss   exc_infos   closes   states   mgrs   connect_dones	   preferred(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   notify_clientïs     
	c    sz   d |  _ t |  _ |  _ d |  _ |  i t j	 o |  i i ƒ  t |  _ n |  i t j	 o |  i i ƒ  t |  _ n d S(   s&   Close the socket and reset everything.s   closedi    N(	   s   selfs   states   Nones   mgrs   clients	   preferreds   conns   closes   sock(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   closes     		c    s   |  i i ƒ  Sd  S(   N(   s   selfs   socks   fileno(   s   self(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   filenos    (	   s   __name__s
   __module__s   __doc__s   __init__s   connect_procedures   test_connections   notify_clients   closes   fileno(    (    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   ConnectWrapperœs   
 					(   s   errnos   selects   sockets   syss	   threadings   times   typess   ThreadedAsyncs   zLOGs   ZODB.POSExceptions   ReadOnlyErrors   ZEO.zrpc.logs   logs   ZEO.zrpc.triggers   triggers   ZEO.zrpc.connections   ManagedConnections   objects   ConnectionManagers   hasattrs   WSAEWOULDBLOCKs   _CONNECT_IN_PROGRESSs
   WSAEISCONNs	   WSAEINVALs   _CONNECT_OKs   EINPROGRESSs   EISCONNs   Threads   ConnectThreads   ConnectWrapper(   s   ConnectThreads   ThreadedAsyncs   sockets   triggers   errnos   ConnectionManagers   _CONNECT_IN_PROGRESSs   syss	   threadings   ConnectWrappers   ReadOnlyErrors   selects   ManagedConnections   times   zLOGs   _CONNECT_OKs   typess   log(    (    s7   /usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys   ? s(   									Å­