- ?cs]dkZdkZdkZdkZdkZdkZdkZdkZdkZdk l Z dk l Z dk lZdklZdefdYZeedo+eifZdeieifZn"eifZdeifZd eifd YZd fd YZdS( N(s ReadOnlyError(slog(strigger(sManagedConnectionsConnectionManagercstZdZ "dddZ1dZ4dZIdZUdZndZd Z d d Z d Z d Z dZ RS(sKeeps a connection up over timeiics"#|i||_$||_%||_&||_'titi |_ (t |_ )d|_ ,t |_-t |_.d|_/ti|idS(Ni(sselfs _parse_addrssaddrssaddrlistsclientstminstmaxs threadings ConditionsLockscondsNones connectionsclosedsthreadstriggers thr_asyncs ThreadedAsyncsregister_loop_callbacks set_async(sselfsaddrssclientstminstmax((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys__init__"s        cs!12d|ii|ifSdS(Ns <%s for %s>(sselfs __class__s__name__saddrlist(sself((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys__repr__1scs4<|i|}=|tj o>||fgSnz@g}Axc|DA]X}B|i|}C|tjoDtdt|nF|i ||fqLWG|SdS(Nsunknown address in list: %s( sselfs _guess_typesaddrss addr_typesNonesaddrlistsaddrs ValueErrorsreprsappend(sselfsaddrssaddrlistsaddrs addr_type((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys _parse_addrs4s  csIJt|tioKtiSnMt|djo+t|dtiot|dtioPtiSnSt SdS(Niii( s isinstancesaddrstypess StringTypessocketsAF_UNIXslensIntTypesAF_INETsNone(sselfsaddr((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys _guess_typeIs Dcs:UVWd|_X|iiYz(Z|i}[t|_\|i}Wd]^|ii X_|tj o[`t da|i b|i dc|i odt dedtinnf|tj oh|ini|itj o j|iikt|_nlti|idS(s6Prevent ConnectionManager from opening new connectionsiNs'CM.close(): stopping and joining threadis(CM.close(): self.thread.join() timed outslevel(sselfsclosedscondsacquiresthreadstsNones connectionsconnsreleaseslogsstopsjoinsisAliveszLOGsWARNINGsclosestriggers ThreadedAsyncsremove_loop_callbacks set_async(sselfstsconn((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pyscloseUs,      csqn{tdt|dti||i o |itjo,}td~t|_d|_ ndS(NsCM.set_async(%s)slevelsCM.set_async(): first calli( slogsreprsmapszLOGsDEBUGsselfsclosedstriggersNones thr_async(sselfsmap((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys set_asyncns   cs|i|iiz|i}|i}Wd|iiX|t j o |t joW|i }|i |iiz|i}Wd|iiXn|t j SdS(sAttempt 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( sselfsconnectscondsacquiresthreadsts connectionsconnsreleasesNones one_attemptseventswait(sselfstsconnsevent((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pysattempt_connects"     icsc|iiz|itj o dSn|i}|tjobtdt||i |i |i |i |_}|i d|in|oYxO|itjo;|iid|itjotdnqWnWd|iiX|o%to|itj ptndS(Ns$CM.connect(): starting ConnectThreadiis$CM.connect(sync=1): still waiting...(sselfscondsacquires connectionsNonesthreadstslogs ConnectThreadsclientsaddrliststminstmaxs setDaemonsstartssyncswaitsreleases __debug__sAssertionError(sselfssyncst((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pysconnects,      cs|td||iiz:||_|ot|_n|ii Wd|ii XdS(NsCM.connect_done(preferred=%s)( slogs preferredsselfscondsacquiresconns connectionsNonesthreads notifyAllsrelease(sselfsconns preferred((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys connect_dones  cs|iizQ||ij o!tddtidSntdt|_Wd|ii X|i i |i o|i ndS(NsCM.close_conn() non-currentslevelsCM.close_conn()(sselfscondsacquiresconns connectionslogszLOGsBLATHERsNonesreleasesclientsnotifyDisconnectedsclosedsconnect(sselfsconn((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys close_conns  csE|iiz|itj SWd|iiXdS(N(sselfscondsacquires connectionsNonesrelease(sself((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys is_connecteds (s__name__s __module__s__doc__s__init__s__repr__s _parse_addrss _guess_typescloses set_asyncsattempt_connectsconnects connect_dones close_conns is_connected(((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pysConnectionManagers     $ sWSAEWOULDBLOCKis ConnectThreadcswtZdZeiiZ dZdZdZ0dZ RdZ `dZ dZ RS(sThread 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. csx  |idd| ||_||_||_||_||_d|_ti |_ dS(Nsnames Connect(%s)i( sselfs_ConnectThread__super_initsaddrlistsmgrsclientstminstmaxsstoppeds threadingsEvents one_attempt(sselfsmgrsclientsaddrliststminstmax((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pys__init__ s      csd|_dS(Ni(sselfsstopped(sself((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pysstopscs |i}d}!d}"x"|i o#|i|}$|ii o%|ii &d}n'|djo(Pn)t i |*|i i o+td,dtin-t|d|i}q'W.td|idS(NiiiKs/CT: still trying to replace fallback connectionslevelisCT: exiting thread: %s(sselfstminsdelayssuccesssattempt_timeoutsstoppedstry_connectings one_attemptsisSetssetstimessleepsmgrs is_connectedslogszLOGsINFOsminstmaxsgetName(sselfsdelayssuccesssattempt_timeout((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pysruns"     cs089tdt|i:ti|};|i}<x5|i D<]$}=|i djo >dSnqRW?z@ti|jo AdSnB|i ||}C|tj o D|SnEti|jo FdSnG|i||}H|tj o I|SnKto| ptWdLMx$|i DM]}N|iqUWO~XPdSdS(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 socketssnotifiediiN(slogslensselfsaddrliststimestimeoutsdeadlines_create_wrappersswrappersskeysswrapsstates_connect_wrapperssrsNones_fallback_wrapperss __debug__sAssertionErrorsclose(sselfstimeoutswrapperssrsdeadlineswrap((s7/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/client.pystry_connecting0s4      csRTh}Ux|iDU]\}}Vt|||i|i}W|i X|i djo>Yx$|i DY]}Z|i qvW[h||