-í Û„?cs#dkZdkZdkZdkZdkZdkZdkZdklZdk l Z l Z dk l Z lZdklZdklZdkZdklZdZdZd fd „ƒYZd efd „ƒYZd eiefd„ƒYZdefd„ƒYZdefd„ƒYZdS(N(ssmac(s ZRPCErrorsDisconnectedError(s short_reprslog(s Marshaller(strigger(s POSExceptions.replyisDelaycs)tZdZd„Zd„Zd„ZRS(sòUsed to delay response to client for synchronous calls When a synchronous call is made and the original handler returns without handling the call, it returns a Delay object that prevents the mainloop from sending a response. cs||_||_||_dS(N(smsgidsselfs send_replys return_error(sselfsmsgids send_replys return_error((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys set_sender)s  cs|i|i|ƒdS(N(sselfs send_replysmsgidsobj(sselfsobj((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysreply.scs4tdtid|ƒ|i|id|d ŒdS(NsError raised in delayed methodserrorii(slogszLOGsERRORsexc_infosselfs return_errorsmsgid(sselfsexc_info((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyserror1s(s__name__s __module__s__doc__s set_sendersreplyserror(((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysDelay!s   sMTDelaycs,tZd„Zd„Zd„Zd„ZRS(Ncstiƒ|_dS(N(s threadingsEventsselfsready(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys__init__7scs'ti||||ƒ|iiƒdS(N(sDelays set_sendersselfsmsgids send_replys return_errorsreadysset(sselfsmsgids send_replys return_error((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys set_sender:scs!|iiƒti||ƒdS(N(sselfsreadyswaitsDelaysreplysobj(sselfsobj((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysreply>s cs!|iiƒti||ƒdS(N(sselfsreadyswaitsDelayserrorsexc_info(sselfsexc_info((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyserrorBs (s__name__s __module__s__init__s set_sendersreplyserror(((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysMTDelay5s   s ConnectioncsstZdZeiiZeiiZeii Z dZ dZ e d„Zd„ZeZeie d„Zd„Zd„Zd„Ze d „Zd „Zd „Zd „Zd „Zd„Zdd„Zd„Zd„Zd„Zd„Z d„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'dd„Z(d „Z)d!„Z*d"„Z+d#d$„Z,RS(%sÇDispatcher for RPC on object on both sides of socket. The connection supports synchronous calls, which expect a return, and asynchronous calls, which do not. It uses the Marshaller class to handle encoding and decoding of method calls and arguments. Marshaller uses pickle to encode arbitrary Python objects. The code here doesn't ever see the wire format. A Connection is designed for use in a multithreaded application, where a synchronous call must block until a response is ready. A socket connection between a client and a server allows either side to invoke methods on the other side. The processes on each end of the socket use a Connection object to manage communication. The Connection deals with decoded RPC messages. They are represented as four-tuples containing: msgid, flags, method name, and a tuple of method arguments. The msgid starts at zero and is incremented by one each time a method call message is sent. Each side of the connection has a separate msgid state. When one side of the connection (the client) calls a method, it sends a message with a new msgid. The other side (the server), replies with a message that has the same msgid, the string ".reply" (the global variable REPLY) as the method name, and the actual return value in the args position. Note that each side of the Connection can initiate a call, in which case it will be the client for that particular call. The protocol also supports asynchronous calls. The client does not wait for a return value for an asynchronous call. The only defined flag is ASYNC. If a method call message has the ASYNC flag set, the server will raise an exception. If a method call raises an Exception, the exception is propagated back to the client via the REPLY message. The client side will raise any exception it receives instead of returning the value to the caller. sZ200sZ201csöt|_tƒ|_d|_d|_t|_t|t i ƒod||_ nd||_ |i ||ƒd|_t|_|iƒh||i<|_tiƒ|_tiƒ|_h|_d|_t|_|i|ƒ|iƒdS(Niszrpc-conn:%s:%ds zrpc-conn:%s(sNonesselfsobjs Marshallersmarshalsclosedsmsgidspeer_protocol_versions isinstancesaddrstypess TupleTypes log_labels_Connection__super_initssocks thr_asyncstriggers_prepare_asyncs_filenos_maps threadingsLocks msgid_locks Conditions replies_condsrepliesswaiting_for_replys delay_sesskeysregister_objects handshake(sselfssocksaddrsobj((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys__init__‹s(             csd|ii|ifSdS(Ns<%s %s>(sselfs __class__s__name__saddr(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys__repr__®scs ti|i||d|ƒdS(Nserror(szLOGsLOGsselfs log_labelslevelsmessageserror(sselfsmessageslevelserror((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyslog³scs@|iodSn|iiƒd|_|iƒ|iƒdS(Ni(sselfscloseds_mapsclears close_triggers_Connection__super_close(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysclose¶s     cs%|itj o|iiƒndS(N(sselfstriggersNonesclose(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys close_trigger¾scs ||_dS(s4Register obj as the true object to invoke methods onN(sobjsself(sselfsobj((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysregister_objectÃscs'|i|_|i|p|iƒdS(N(sselfsrecv_handshakes message_inputsmessage_outputsprotosprotocol_version(sselfsproto((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys handshakeÇs cs…|`||_|i|jo |ijno|id|dtiƒn1|idt |ƒdti ƒt d|ƒ‚dS(Nsreceived handshake %rslevelsbad handshake %ssbad handshake %r( sselfs message_inputsprotospeer_protocol_versionsoldest_protocol_versionsprotocol_versionslogszLOGsINFOs short_reprsERRORs ZRPCError(sselfsproto((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysrecv_handshakeÖs  $ cs\|ii|ƒ\}}}}|tjo|i |||ƒn|i ||||ƒdS(s,Decoding an incoming message and dispatch itN( sselfsmarshalsdecodesmessagesmsgidsflagssnamesargssREPLYs handle_replyshandle_request(sselfsmessagesflagssnamesmsgidsargs((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys message_inputàs  csF|iiƒz$||f|i|<|iiƒWd|iiƒXdS(N( sselfs replies_condsacquiresflagssargssrepliessmsgids notifyAllsrelease(sselfsmsgidsflagssargs((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys handle_replyñs c s™|i|ƒ o)d|t|iƒf}t|ƒ‚nt|i|ƒ}y*d|_ z||Œ}Wdd|_ XWn|t t fj o ‚nbtj oU}tiƒ}|id||ftid|ƒ|d }|i|||ŒSnX|t@o1|tj o td|t|ƒfƒ‚nn>t|tƒo|i||i|iƒn|i||ƒ|io|i |iƒt|_ndS(NsInvalid method name: %s on %siis%s() raised exception: %sserroris!async method %s returned value %s(!sselfs check_methodsnamesreprsobjsmsgs ZRPCErrorsgetattrsmethswaiting_for_replysargssrets SystemExitsKeyboardInterrupts Exceptionssyssexc_infoserrorslogszLOGsINFOs return_errorsmsgidsflagssASYNCsNones short_reprs isinstancesDelays set_senders send_replys delay_sesskeys _Connection__super_setSessionKey( sselfsmsgidsflagssnamesargssmsgsmethsretserror((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyshandle_requestüs:      $ csBtiƒdtjotiƒ‚n|idƒ|iƒdS(NisError caught in asyncore(ssyssexc_infos SystemExitsselfs log_errorsclose(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys handle_error$s sNo error message suppliedcs#|i|tidtiƒƒdS(Nserror(sselfslogsmsgszLOGsERRORssyssexc_info(sselfsmsg((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys log_error*scs,|idƒotSnt|i|ƒSdS(Ns_(snames startswithsNoneshasattrsselfsobj(sselfsname((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys check_method-scs§y|ii|dt|ƒ}Wnj|iij oXyt|ƒ}Wn d}nXt d|ƒ}|ii|dtt |fƒ}nX|i |ƒ|i ƒdS(Nis sCouldn't pickle return %.100s(sselfsmarshalsencodesmsgidsREPLYsretsmsgserrorss short_reprsrs ZRPCErrorserrsmessage_outputspoll(sselfsmsgidsretsrserrsmsg((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys send_reply3s & cs÷|t@o|id|ƒdSnt|ƒtij o||f}ny%|i i |dt ||fƒ}Wnj|i ij oXyt|ƒ}Wn d}nXtd|ƒ}|i i |dt t|fƒ}nX|i|ƒ|iƒdS(Ns&Asynchronous call raised exception: %sis sCouldn't pickle error %.100s(sflagssASYNCsselfs log_errorstypes err_valuestypess InstanceTypeserr_typesmarshalsencodesmsgidsREPLYsmsgserrorss short_reprsrs ZRPCErrorserrsmessage_outputspoll(sselfsmsgidsflagsserr_types err_valueserrsrsmsg((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys return_error@s  % & cs(|io ||_n|i|ƒdS(N(sselfswaiting_for_replyskeys delay_sesskeys _Connection__super_setSessionKey(sselfskey((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys setSessionKeySs  csk|iiƒz|i}|id|_Wd|iiƒX|ii||||ƒ}|i |ƒ|SdS(Ni( sselfs msgid_locksacquiresmsgidsreleasesmarshalsencodesflagssmethodsargssbufsmessage_output(sselfsmethodsargssflagssmsgidsbuf((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys send_call\s   cs±|io tƒ‚n|i||dƒ}|i|ƒ\}}t |t i ƒo>t |ƒdjo+t|dƒt ijot|dtƒo|d}|‚n|SdS(Nii(sselfsclosedsDisconnectedErrors send_callsmethodsargssmsgidswaitsr_flagssr_argss isinstancestypess TupleTypeslenstypes ClassTypes issubclasss Exceptionsinst(sselfsmethodsargssmsgidsr_argssr_flagssinst((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyscallks  T  csG|io tƒ‚n|i||dƒ}tid|i ƒ|SdS(Nif0.01( sselfsclosedsDisconnectedErrors send_callsmethodsargssmsgidsasyncorespolls_map(sselfsmethodsargssmsgid((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys_deferred_call~s   csr|i|ƒ\}}t|tiƒo+t|dƒti jot |dt ƒo|d}|‚n|SdS(Nii( sselfswaitsmsgidsr_flagssr_argss isinstancestypess TupleTypestypes ClassTypes issubclasss Exceptionsinst(sselfsmsgidsr_flagssinstsr_args((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys_deferred_wait…s A  cs8|io tƒ‚n|i||tƒ|iƒdS(N(sselfsclosedsDisconnectedErrors send_callsmethodsargssASYNCspoll(sselfsmethodsargs((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys callAsyncs  cs.|io tƒ‚n|i||tƒdS(N(sselfsclosedsDisconnectedErrors send_callsmethodsargssASYNC(sselfsmethodsargs((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyscallAsyncNoPoll•s  csd|_ti|iƒdS(Ni(sselfs thr_asyncs ThreadedAsyncsregister_loop_callbacks set_async(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys_prepare_asyncŸs cstƒ|_d|_dS(Ni(striggersselfs thr_async(sselfsmap((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys set_async¥s cs|iodSndSdS(Nii(sselfs thr_async(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysis_async©s i csiy|iiƒWnQtj oE|iiƒtƒ|_|djo|id|dƒnnXdS(Nistryagaini(sselfstriggers pull_triggersOSErrorsclosestryagains _pull_trigger(sselfstryagain((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys _pull_trigger°s   csR|iƒo|iƒnd}|iiƒzxdo|io tƒ‚n|ii |ƒ}|t j o|i|=|Sn|iƒo|ii dƒn”|iiƒzuy2ti||iƒ|djo||7}nWn<tij o-}|id|dtiƒ|iƒnXWd|iiƒXq4WWd|iiƒXdS(s,Invoke asyncore mainloop and wait for reply.f0.001if10.0f1.0s$Closing. asyncore.poll() raised %s.slevelN(sselfsis_asyncs _pull_triggersdelays replies_condsacquiresclosedsDisconnectedErrorsrepliessgetsmsgidsreplysNoneswaitsreleasesasyncorespolls_mapsselectserrorserrslogszLOGsBLATHERsclose(sselfsmsgidsdelayserrsreply((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyswait¹sB           cs#x|iƒo|iƒqWdS(s/Invoke poll() until the output buffer is empty.N(sselfswritablespoll(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysflushæs  cs2|iƒo|iƒntid|iƒdS(s4Invoke asyncore mainloop to get pending message out.f0.0N(sselfsis_asyncs _pull_triggersasyncorespolls_map(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyspollís  ic s`|iƒodSn|ig}}g}x.|o|i o|iƒo|ig}ng}y%t i ||||ƒ\}}}Wn<t i j o-}|dtijo d}q.n‚nXd}|o>y|iƒWn)tij o ‚n|iƒnXn|o>y|iƒWn)tij o ‚n|iƒnXnq.WdS(s7Invoke mainloop until any pending messages are handled.Ni(sselfsis_asyncs_filenosrsr_insx_insclosedswritablesw_insselectstimeoutswsxserrorserrserrnosEINTRshandle_read_eventsasyncoresExitNows handle_errorshandle_write_event( sselfstimeoutserrsx_insrswsxsr_insw_in((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyspendingösB   % (-s__name__s __module__s__doc__ssmacsSizedMessageAsyncConnections__init__s_Connection__super_initscloses_Connection__super_closes setSessionKeys _Connection__super_setSessionKeysoldest_protocol_versionsprotocol_versionsNones__repr__s__str__szLOGsBLATHERslogs close_triggersregister_objects handshakesrecv_handshakes message_inputs handle_replyshandle_requests handle_errors log_errors check_methods send_replys return_errors send_callscalls_deferred_calls_deferred_waits callAsyncscallAsyncNoPolls_prepare_asyncs set_asyncsis_asyncs _pull_triggerswaitsflushspollspending(((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys ConnectionFsL +    #       (            -  sManagedServerConnectioncs2tZdZeiZeiZd„Zd„ZRS(s Server-side Connection subclass.cs0||_|i|||ƒ|ii|ƒdS(N(smgrsselfs$_ManagedServerConnection__super_initssocksaddrsobjsnotifyConnected(sselfssocksaddrsobjsmgr((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys__init__0s cs+|iiƒ|ii|ƒ|iƒdS(N(sselfsobjsnotifyDisconnectedsmgrs close_conns%_ManagedServerConnection__super_close(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysclose5s (s__name__s __module__s__doc__s Connections__init__s$_ManagedServerConnection__super_initscloses%_ManagedServerConnection__super_close(((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysManagedServerConnection+s    sManagedConnectioncsztZdZeiZeiZd„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „ZRS( s Client-side Connection subclass.cs*||_|i|||ƒ|iƒdS(N(smgrsselfs_ManagedConnection__super_initssocksaddrsobjscheck_mgr_async(sselfssocksaddrsobjsmgr((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys__init__?s cs%|i|_|i|_g|_dS(N(sselfsrecv_handshakes message_inputs queue_outputsmessage_outputs output_queue(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys handshakeks  cs|ii|ƒdS(N(sselfs output_queuesappendsmessage(sselfsmessage((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys queue_outputqscsf|`t||iƒ}ti||ƒ|i|ƒ|i}|`x|D]}|i|ƒqKWdS(N( sselfsmessage_outputsminsprotosprotocol_versions Connectionsrecv_handshakes output_queuesqueuesmessage(sselfsprotosqueuesmessage((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysrecv_handshakets  cs |`dS(N(sselfstrigger(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys close_trigger€scsdS(N((sselfsmap((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys set_async„scsdS(N((sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys_prepare_async‡scs@|i o |iio d|_|ii|_dSndSdS(Nii(sselfs thr_asyncsmgrstrigger(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pyscheck_mgr_async‹s  cs |iodSn|iƒSdS(Ni(sselfs thr_asyncscheck_mgr_async(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysis_async”s cs|ii|ƒ|iƒdS(N(sselfsmgrs close_conns_ManagedConnection__super_close(sself((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysclosešs(s__name__s __module__s__doc__s Connections__init__s_ManagedConnection__super_initscloses_ManagedConnection__super_closes handshakes queue_outputsrecv_handshakes close_triggers set_asyncs_prepare_asyncscheck_mgr_asyncsis_async(((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pysManagedConnection:s    ,      (sasyncoreserrnosselectssyss threadingstypess ThreadedAsyncsZEO.zrpcssmacsZEO.zrpc.errors ZRPCErrorsDisconnectedErrors ZEO.zrpc.logs short_reprslogsZEO.zrpc.marshals MarshallersZEO.zrpc.triggerstriggerszLOGsZODBs POSExceptionsREPLYsASYNCsDelaysMTDelaysSizedMessageAsyncConnectionsobjects ConnectionsManagedServerConnectionsManagedConnection(sManagedServerConnectionsasyncoressmacs ConnectionsMTDelaysDisconnectedErrorsREPLYsASYNCs POSExceptionstypesssyss short_reprs ThreadedAsyncslogs threadingserrnosDelays MarshallerstriggersselectsManagedConnectionszLOGs ZRPCError((s;/usr/pkg/lib/python2.2/site-packages/ZEO/zrpc/connection.pys?s*            ÿæ