;i  dZddlZddlZddlmZmZmZmZmZddl Z ddl m Z ddl m Z ddl mZejeZe jje jje jje jje jje jje jje jje jje jjiZie jj e jj!e jj"e jj#e jj$e jj%e jj&e jj'e jj(e jj)e jj*e jj+e jj,e jj-e jj.e jj/e jj0e jj1e jj2e jj3e jj4e jj5e jj6e jj7e jj8e jj9e jj:e jj;e jj<e jj=e jj>e jj?e jj@e jjAZBdeBCDZDdZEd ZFd ed eGfd ZHd ed eIfdZJdedeee dfdeId efdZKdedeed eGfdZLdeGdee d efdZMdeIdeId eIfdZNdedeOfdePdeegdffdZQ d%dedeOfd egeOfdeePdeegdfd eOf d!ZRd"eId#eSd eSfd$ZTdS)&zShared implementation.N)AnyAnyStrCallableOptionalUnion)cygrpc)DeserializingFunction)SerializingFunctionci|]\}}|| Sr ).0 cygrpc_code grpc_codes @C:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\grpc/_common.py r6s.%%% Y{%%%g?zjFailed to bind to address %s; set GRPC_VERBOSITY=debug environment variable to see detailed error message.sreturncZt|tr|S|dS)Nutf8) isinstancebytesencode)rs rrrCs+!U 88F  rbc\t|tr|ddS|S)Nzutf-8replace)rrdecode)rs rrrIs-!U,xx+++ Hrmessage transformerexception_messagecx||S ||S#t$rt|YdSwxYw)N) Exception_LOGGER exception)rrr s r _transformr%Os[ {7### +,,,tts $99 serializerc$t||dS)NzException serializing message!r%)rr&s r serializer)]s gz+K L LLrserialized_message deserializerc$t||dS)Nz Exception deserializing message!r()r*r+s r deserializer-as L*L  rgroupmethodc.d||S)Nz/{}/{})format)r.r/s rfully_qualified_methodr2is ??5& ) ))rwait_fn.timeoutspin_cbc:||| |dSdS)N)r4r )r3r4r5s r _wait_oncer7ms4  GG rwait_complete_fnc8|+|s t|t|| nltj|z}|sLt|tjz t}|dkrdSt||||LdS)adBlocks waiting for an event without blocking the thread indefinitely. See https://github.com/grpc/grpc/issues/19464 for full context. CPython's `threading.Event.wait` and `threading.Condition.wait` methods, if invoked without a timeout kwarg, may block the calling thread indefinitely. If the call is made from the main thread, this means that signal handlers may not run for an arbitrarily long period of time. This wrapper calls the supplied wait function with an arbitrary short timeout to ensure that no signal handler has to wait longer than MAXIMUM_WAIT_TIMEOUT before executing. Args: wait_fn: A callable acceptable a single float-valued kwarg named `timeout`. This function is expected to be one of `threading.Event.wait` or `threading.Condition.wait`. wait_complete_fn: A callable taking no arguments and returning a bool. When this function returns true, it indicates that waiting should cease. timeout: An optional float-valued number of seconds after which the wait should cease. spin_cb: An optional Callable taking no arguments and returning nothing. This callback will be called on each iteration of the spin. This may be used for, e.g. work related to forking. Returns: True if a timeout was supplied and it was reached. False otherwise. NrTF)r7MAXIMUM_WAIT_TIMEOUTtimemin)r3r8r4r5end remainings rwaitr?wsB""$$ ? w 4g > > >#"$$ ?ikkG#""$$ 4C$)++-/CDDI1}}t w 7 3 3 3 #"$$ 4 5raddressportc@|dkrtt|z|S)akValidates if the port binding succeed. If the port returned by Core is 0, the binding is failed. However, in that case, the Core API doesn't return a detailed failing reason. The best we can do is raising an exception to prevent further confusion. Args: address: The address string to be bound. port: An int returned by core r) RuntimeError"_ERROR_MESSAGE_PORT_BINDING_FAILED)r@rAs rvalidate_port_binding_resultrEs( qyy=GHHH r)NN)U__doc__loggingr;typingrrrrrgrpc grpc._cythonr grpc._typingr r getLogger__name__r#ConnectivityStateidleChannelConnectivityIDLE connecting CONNECTINGreadyREADYtransient_failureTRANSIENT_FAILUREshutdownSHUTDOWN1CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY StatusCodeokOK cancelled CANCELLEDunknownUNKNOWNinvalid_argumentINVALID_ARGUMENTdeadline_exceededDEADLINE_EXCEEDED not_found NOT_FOUNDalready_existsALREADY_EXISTSpermission_deniedPERMISSION_DENIEDunauthenticatedUNAUTHENTICATEDresource_exhaustedRESOURCE_EXHAUSTEDfailed_preconditionFAILED_PRECONDITIONabortedABORTED out_of_range OUT_OF_RANGE unimplemented UNIMPLEMENTEDinternalINTERNAL unavailable UNAVAILABLE data_loss DATA_LOSS!CYGRPC_STATUS_CODE_TO_STATUS_CODEitems!STATUS_CODE_TO_CYGRPC_STATUS_CODEr:rDrrstrrr%r)r-r2boolfloatr7r?intrEr rrrs 99999999999999 ......,,,,,, ' H % % !4#;#@ ')A)L "D$<$B .0H0Z %t'?'H 51% $/,% !:% t6% &(H %  ')J %  !: % $do&D% ')J% %t'F% ($/*L% )4?+N% t6% "DO$@% #T_%B%  8%  !4?#>!%" !:#%!&%%"C"I"I"K"K%%%! O# f  f       *,A4GH      MsM1D(EM%MMMM-56K-L*#*s*s**** c4i  hr4x( ) $,0 ++ c4i +r4x(+e_+hr4x( ) +  ++++\#SSr