grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026ó /úkDj8ãó¬•SrSrSSKrSSKrSSKrSSKrSSKrSSKJr SSK J r /SQr \ "\S5(a\ R/SQ5 \ "\S 5(a4\ R/S Q5 \ "\S5(a\ RS S /5 \ "\S 5(a \RrO \R r"SS5r"SS\5r"SS\5r\ "\S5(a "SS5r"SS\5r"SS5r"SS5r\ "\S5(a"SS\\5r"SS\\5r"S S!\\5r"S"S#\\5r\ "\S 5(aT"S$S%\5r"S&S'\5r"S(S)\\5r"S*S+\\5r \ "\S5(a"S,S \\5r!"S-S \\5r""S.S/5r#"S0S1\#5r$"S2S3\5r%"S4S5\#5r&g)6aqGeneric socket server classes. This module tries to capture the various aspects of defining a server: For socket-based servers: - address family: - AF_INET{,6}: IP (Internet Protocol) sockets (default) - AF_UNIX: Unix domain sockets - others, e.g. AF_DECNET are conceivable (see - socket type: - SOCK_STREAM (reliable stream, e.g. TCP) - SOCK_DGRAM (datagrams, e.g. UDP) For request-based servers (including socket-based): - client address verification before further looking at the request (This is actually a hook for any processing that needs to look at the request before anything else, e.g. logging) - how to handle multiple requests: - synchronous (one request is handled at a time) - forking (each request is handled by a new process) - threading (each request is handled by a new thread) The classes in this module favor the server type that is simplest to write: a synchronous TCP/IP server. This is bad class design, but saves some typing. (There's also the issue that a deep class hierarchy slows down method lookups.) There are five classes in an inheritance diagram, four of which represent synchronous servers of four types: +------------+ | BaseServer | +------------+ | v +-----------+ +------------------+ | TCPServer |------->| UnixStreamServer | +-----------+ +------------------+ | v +-----------+ +--------------------+ | UDPServer |------->| UnixDatagramServer | +-----------+ +--------------------+ Note that UnixDatagramServer derives from UDPServer, not from UnixStreamServer -- the only difference between an IP and a Unix stream server is the address family, which is simply repeated in both unix server classes. Forking and threading versions of each type of server can be created using the ForkingMixIn and ThreadingMixIn mix-in classes. For instance, a threading UDP server class is created as follows: class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass The Mix-in class must come first, since it overrides a method defined in UDPServer! Setting the various member variables also changes the behavior of the underlying server mechanism. To implement a service, you must derive a class from BaseRequestHandler and redefine its handle() method. You can then run various versions of the service by combining one of the server classes with your request handler class. The request handler class must be different for datagram or stream services. This can be hidden by using the request handler subclasses StreamRequestHandler or DatagramRequestHandler. Of course, you still have to use your head! For instance, it makes no sense to use a forking server if the service contains state in memory that can be modified by requests (since the modifications in the child process would never reach the initial state kept in the parent process and passed to each child). In this case, you can use a threading server, but you will probably have to use locks to avoid two requests that come in nearly simultaneous to apply conflicting changes to the server state. On the other hand, if you are building e.g. an HTTP server, where all data is stored externally (e.g. in the file system), a synchronous class will essentially render the service "deaf" while one request is being handled -- which may be for a very long time if a client is slow to read all the data it has requested. Here a threading or forking server is appropriate. In some cases, it may be appropriate to process part of a request synchronously, but to finish processing in a forked child depending on the request data. This can be implemented by using a synchronous server and doing an explicit fork in the request handler class handle() method. Another approach to handling multiple simultaneous requests in an environment that supports neither threads nor fork (or where these are too expensive or inappropriate for the service) is to maintain an explicit table of partially finished requests and to use a selector to decide which request to work on next (or whether to handle a new incoming request). This is particularly important for stream services where each client can potentially be connected for a long time (if threads or subprocesses cannot be used). Future work: - Standard classes for Sun RPC (which uses either UDP or TCP) - Standard mix-in classes to implement various authentication and encryption schemes XXX Open problems: - What to do with out-of-band data? BaseServer: - split generic "request" functionality out into BaseServer class. Copyright (C) 2000 Luke Kenneth Casson Leighton example: read entries from a SQL database (requires overriding get_request() to return a table entry from the database). entry is processed by a RequestHandlerClass. z0.4éN)ÚBufferedIOBase)Ú monotonic) Ú BaseServerÚ TCPServerÚ UDPServerÚThreadingUDPServerÚThreadingTCPServerÚBaseRequestHandlerÚStreamRequestHandlerÚDatagramRequestHandlerÚThreadingMixInÚfork)ÚForkingUDPServerÚForkingTCPServerÚ ForkingMixInÚAF_UNIX)ÚUnixStreamServerÚUnixDatagramServerÚThreadingUnixStreamServerÚThreadingUnixDatagramServerÚForkingUnixStreamServerÚForkingUnixDatagramServerÚ PollSelectorcó†•\rSrSrSrSrSrSrSSjrSr Sr S r S r S r S rS rSrSrSrSrSrSrSrSrg)ré›aSBase class for server classes. Methods for the caller: - __init__(server_address, RequestHandlerClass) - serve_forever(poll_interval=0.5) - shutdown() - handle_request() # if you do not use serve_forever() - fileno() -> int # for selector Methods that may be overridden: - server_bind() - server_activate() - get_request() -> request, client_address - handle_timeout() - verify_request(request, client_address) - server_close() - process_request(request, client_address) - shutdown_request(request) - close_request(request) - service_actions() - handle_error() Methods for derived classes: - finish_request(request, client_address) Class variables that may be overridden by derived classes or instances: - timeout - address_family - socket_type - allow_reuse_address - allow_reuse_port Instance variables: - RequestHandlerClass - socket Ncó^•XlX l[R"5UlSUlg)ú/Constructor. May be extended, do not override.FN)Úserver_addressÚRequestHandlerClassÚ threadingÚEventÚ_BaseServer__is_shut_downÚ_BaseServer__shutdown_request)Úselfrrs Ú3/opt/alt/python313/lib64/python3.13/socketserver.pyÚ__init__ÚBaseServer.__init__Ës%€à,ÔØ#6Ô Ü'ŸošoÓ/ˆÔØ"'ˆÕócó•g©zCCalled by constructor to activate the server. May be overridden. N©©r$s r%Úserver_activateÚBaseServer.server_activateÒó€ð r(có,•URR5 [5nURU[R 5 UR (d]URU5nUR (aO:U(aUR5 UR5 UR (dM]SSS5 SUlURR5 g!,(df  N0=f!SUlURR5 f=f)z±Handle one request at a time until shutdown. Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread. NF) r"ÚclearÚ_ServerSelectorÚregisterÚ selectorsÚ EVENT_READr#ÚselectÚ_handle_request_noblockÚservice_actionsÚset)r$Ú poll_intervalÚselectorÚreadys r%Ú serve_foreverÚBaseServer.serve_foreverÚs΀ð ×Ñ×!Ñ!Ô#ð &ô !Ô" hØ×!Ñ! $¬ ×(<Ñ(<Ô=à×1×1Ø$ŸO™O¨MÓ:�Eà×.×.ØÞØ×4Ñ4Ô6à×(Ñ(Ô*ð×1×1Ñ1÷#ð',ˆDÔ #Ø × Ñ × #Ñ #Õ %÷#Õ"ûð',ˆDÔ #Ø × Ñ × #Ñ #Õ %ús#œ C0¦B CÂ5C0à C-Ã)C0Ã0#DcóF•SUlURR5 g)z Stops the serve_forever loop. Blocks until the loop has finished. This must be called while serve_forever() is running in another thread, or it will deadlock. TN)r#r"Úwaitr,s r%ÚshutdownÚBaseServer.shutdown÷s€ð#'ˆÔØ ×Ñ× Ñ Õ"r(có•g)z‰Called by the serve_forever() loop. May be overridden by a subclass / Mixin to implement any code that needs to be run during the loop. Nr+r,s r%r8ÚBaseServer.service_actionsr/r(cóô•URR5nUc URnO"URb[XR5nUb [ 5U-n[ 5nUR U[R5 URU5(aUR5sSSS5 $Ub,W[ 5- nUS:aUR5sSSS5 $M`!,(df  g=f)z?Handle one request, possibly blocking. Respects self.timeout. Nr) ÚsocketÚ gettimeoutÚtimeoutÚminÚtimer2r3r4r5r6r7Úhandle_timeout)r$rHÚdeadliner;s r%Úhandle_requestÚBaseServer.handle_requestsÑ€ð—+‘+×(Ñ(Ó*ˆØ ‰?Ø—l‘l‰GØ �\‰\Ñ %ܘ'§<¡<Ó0ˆGØ Ñ Ü“v Ñ'ˆHôÔ  (Ø × Ñ ˜d¤I×$8Ñ$8Ô 9àØ—?‘? 7×+Ñ+Ø×7Ñ7Ó9÷ Ñ ðÑ*Ø"*¬T«VÑ"3˜Ø" Q›;Ø#'×#6Ñ#6Ó#8÷Ñ ñ÷Õ úsÁ'AC)Â8%C)Ã'C)Ã) C7cóF•UR5upURX5(aURX5 gUR U5 g![a gf=f![a% UR X5 UR U5 g UR U5 e=f)zÊHandle one request, without blocking. I assume that selector.select() has returned that the socket is readable before this function was called, so there should be no risk of blocking in get_request(). N)Ú get_requestÚOSErrorÚverify_requestÚprocess_requestÚ ExceptionÚ handle_errorÚshutdown_request©r$ÚrequestÚclient_addresss r%r7Ú"BaseServer._handle_request_noblock1sŸ€ð Ø&*×&6Ñ&6Ó&8Ñ #ˆGð × Ñ ˜w× 7Ñ 7ð Ø×$Ñ$ WÕ=ð × !Ñ ! 'Õ *øôó Ù ð ûô ó /Ø×!Ñ! 'Ô:Ø×%Ñ% gÖ.ð Ø×%Ñ% gÔ.Øús"‚A«AÁ AÁAÁ,B  B có•g)zSCalled if no new request arrives within self.timeout. Overridden by ForkingMixIn. Nr+r,s r%rKÚBaseServer.handle_timeoutHs€ð r(có•g)z^Verify the request. May be overridden. Return True if we should proceed with this request. Tr+rWs r%rRÚBaseServer.verify_requestOs€ð r(cóH•URX5 URU5 g)zFCall finish_request. Overridden by ForkingMixIn and ThreadingMixIn. N)Úfinish_requestrVrWs r%rSÚBaseServer.process_requestWs €ð ×јGÔ4Ø ×јgÕ&r(có•g©z4Called to clean-up the server. May be overridden. Nr+r,s r%Ú server_closeÚBaseServer.server_close`r/r(có(•URXU5 g)z8Finish one request by instantiating RequestHandlerClass.N)rrWs r%r`ÚBaseServer.finish_requesths€à × Ñ  ¸$Õ?r(có&•URU5 g©z3Called to shutdown and close an individual request.N©Ú close_request©r$rXs r%rVÚBaseServer.shutdown_requestló€à ×ј7Õ#r(có•g©z)Called to clean up an individual request.Nr+rls r%rkÚBaseServer.close_requestpó€à r(có¾•[S[RS9 [SU[RS9 SSKnUR 5 [S[RS9 g)zdHandle an error gracefully. May be overridden. The default is to print a traceback and continue. z(----------------------------------------)Úfilez4Exception occurred during processing of request fromrN)ÚprintÚsysÚstderrÚ tracebackÚ print_exc)r$rXrYrxs r%rUÚBaseServer.handle_errortsC€ô ˆfœ3Ÿ:™:Ò&Ü ÐDØ ¤§¡ò -ãØ×ÑÔÜ ˆfœ3Ÿ:™:Ó&r(có•U$©Nr+r,s r%Ú __enter__ÚBaseServer.__enter__�s€Øˆ r(có$•UR5 gr|)rd)r$Úargss r%Ú__exit__ÚBaseServer.__exit__„s€Ø ×ÑÕr()rÚ__is_shut_downÚ__shutdown_requestr)gà?)Ú__name__Ú __module__Ú __qualname__Ú__firstlineno__Ú__doc__rHr&r-r=rAr8rMr7rKrRrSrdr`rVrkrUr}r�Ú__static_attributes__r+r(r%rr›se†ñ*ðX€Gò(ò ô&ò:#ò ò&9ò:+ò. òò'ò ò@ò$ò ò 'òõr(rcóˆ•\rSrSrSr\R r\Rr Sr Sr Sr SSjr SrSrSrS rS rS rS rS rg)riˆaÊBase class for various socket-based server classes. Defaults to synchronous IP stream (i.e., TCP). Methods for the caller: - __init__(server_address, RequestHandlerClass, bind_and_activate=True) - serve_forever(poll_interval=0.5) - shutdown() - handle_request() # if you don't use serve_forever() - fileno() -> int # for selector Methods that may be overridden: - server_bind() - server_activate() - get_request() -> request, client_address - handle_timeout() - verify_request(request, client_address) - process_request(request, client_address) - shutdown_request(request) - close_request(request) - handle_error() Methods for derived classes: - finish_request(request, client_address) Class variables that may be overridden by derived classes or instances: - timeout - address_family - socket_type - request_queue_size (only for stream sockets) - allow_reuse_address - allow_reuse_port Instance variables: - server_address - RequestHandlerClass - socket éFcó•[RXU5 [R"URUR5UlU(a"UR 5 UR 5 gg! UR5 e=f)rN)rr&rFÚaddress_familyÚ socket_typeÚ server_bindr-rd)r$rrÚbind_and_activates r%r&ÚTCPServer.__init__Âso€ä×јDÐ2EÔFÜ—m’m D×$7Ñ$7Ø$(×$4Ñ$4ó6ˆŒ æ ð Ø× Ñ Ô"Ø×$Ñ$Õ&ð øð Ø×!Ñ!Ô#Øús Á A1Á1Bcód•UR(aN[[S5(a9URR[R[R S5 UR (a|[[S5(agUR[R[R4;a9URR[R[RS5 URRUR5 URR5Ul g)z?Called by constructor to bind the socket. May be overridden. Ú SO_REUSEADDRéÚ SO_REUSEPORTN)Úallow_reuse_addressÚhasattrrFÚ setsockoptÚ SOL_SOCKETr”Úallow_reuse_portrŽÚAF_INETÚAF_INET6r–ÚbindrÚ getsocknamer,s r%r�ÚTCPServer.server_bindÏs¼€ð × #× #¬´¸×(GÑ(GØ �K‰K× "Ñ "¤6×#4Ñ#4´f×6IÑ6IÈ1Ô Mð × !× !¤g¬f°n×&EÑ&EØ×#Ñ#¬¯©¼¿¹Ð'HÓHà �K‰K× "Ñ "¤6×#4Ñ#4´f×6IÑ6IÈ1Ô MØ � ‰ ×ј×,Ñ,Ô-Ø"Ÿk™k×5Ñ5Ó7ˆÕr(cóN•URRUR5 gr*)rFÚlistenÚrequest_queue_sizer,s r%r-ÚTCPServer.server_activateás€ð � ‰ ×ј4×2Ñ2Õ3r(có8•URR5 grc)rFÚcloser,s r%rdÚTCPServer.server_closeés€ð � ‰ ×ÑÕr(có6•URR5$)z=Return socket file number. Interface required by selector. )rFÚfilenor,s r%r©ÚTCPServer.filenoñó€ð �{‰{×!Ñ!Ó#Ð#r(có6•URR5$)zIGet the request and client address from the socket. May be overridden. )rFÚacceptr,s r%rPÚTCPServer.get_requestùr«r(có†•UR[R5 UR U5 g![a Nf=fri)rArFÚSHUT_WRrQrkrls r%rVÚTCPServer.shutdown_requests?€ð ð × Ñ œVŸ^™^Ô ,ð ×ј7Õ#øôó Ù ð ús‚3³ A¿Acó$•UR5 grp)r¦rls r%rkÚTCPServer.close_request s €à� ‰ �r()rrFN)T)r…r†r‡rˆr‰rFrœrŽÚ SOCK_STREAMr�r£r—r›r&r�r-rdr©rPrVrkrŠr+r(r%rrˆsX†ñ,ð\—^‘^€Nà×$Ñ$€KàÐàÐàÐô ò8ò$4òò$ò$ò$õr(rcóT•\rSrSrSrSrSr\Rr Sr Sr Sr Sr SrS rg ) rizUDP server class.Fi cón•URRUR5upXR4U4$r|)rFÚrecvfromÚmax_packet_size)r$ÚdataÚ client_addrs r%rPÚUDPServer.get_requests1€Ø ŸK™K×0Ñ0°×1EÑ1EÓFшؗk‘kÐ" KÐ/Ð/r(có•gr|r+r,s r%r-ÚUDPServer.server_activate rrr(có&•URU5 gr|rjrls r%rVÚUDPServer.shutdown_request$rnr(có•gr|r+rls r%rkÚUDPServer.close_request(rrr(r+N)r…r†r‡rˆr‰r—r›rFÚ SOCK_DGRAMr�r¸rPr-rVrkrŠr+r(r%rrs5†áàÐàÐà×#Ñ#€Kà€Oò0ò ò$õ r(rcó\^•\rSrSrSrSrSrSrSrSS.S jr S r S r S r U4S jr SrU=r$)ri-z5Mix-in class to handle each request in a new process.i,Né(TF©ÚblockingcóÒ•URcg[UR5UR:¼aZ[R"SS5up#URR U5 [UR5UR:¼aMZURR5HPnU(aSO[Rn[R"X$5up#URR U5 MR g![ a URR5 Nº[a M¡f=f![ a URR U5 M³[a M¿f=f)z7Internal routine to wait for children that have exited.Néÿÿÿÿr) Úactive_childrenÚlenÚ max_childrenÚosÚwaitpidÚdiscardÚChildProcessErrorr1rQÚcopyÚWNOHANG)r$rÆÚpidÚ_Úflagss r%Úcollect_childrenÚForkingMixIn.collect_children6s"€à×#Ñ#Ñ+Øô�d×*Ñ*Ó+¨t×/@Ñ/@Ó@ðÜŸZšZ¨¨AÓ.‘F�CØ×(Ñ(×0Ñ0°Ô5ô�d×*Ñ*Ó+¨t×/@Ñ/@Õ@ð×+Ñ+×0Ñ0Ö2�ð Þ!)™A¬r¯z©z�EÜŸZšZ¨Ó3‘F�Cð×(Ñ(×0Ñ0°Ö5ò 3øô)ó1à×(Ñ(×.Ñ.Ö0ÜóÚðûô)ó6à×(Ñ(×0Ñ0°×5ÜóÚðús0³4C;Â*A D1Ã;$D.Ä! D.Ä-D.Ä1%E&Å E&Å%E&có$•UR5 g)z^Wait for zombies after self.timeout seconds of inactivity. May be extended, do not override. N©rÕr,s r%rKÚForkingMixIn.handle_timeoutYó€ð × !Ñ !Õ #r(có$•UR5 g)z…Collect the zombie child processes regularly in the ForkingMixIn. service_actions is called in the BaseServer's serve_forever loop. NrØr,s r%r8ÚForkingMixIn.service_actions`rÚr(cóR•[R"5nU(aIURc[5UlURR U5 UR U5 gSnUR X5 SnURU5 [R"U5 g![a URX5 NFf=f![R"U5 f=f!URU5 [R"U5 f![R"U5 f=f=f)z-Fork a new subprocess to process the request.Nr•r) rÌrrÉr9Úaddrkr`rTrUrVÚ_exit)r$rXrYrÒÚstatuss r%rSÚForkingMixIn.process_requestgsã€ä—'’'“)ˆCÞà×'Ñ'Ñ/Ü+.«5�DÔ(Ø×$Ñ$×(Ñ(¨Ô-Ø×"Ñ" 7Ô+Øð�ð )Ø×'Ñ'¨Ô@Ø�Fð)Ø×-Ñ-¨gÔ6䟚 Õ(øô !ó?Ø×%Ñ% gÖ>ð?ûô Ÿš Õ(ûð)Ø×-Ñ-¨gÔ6䟚 Õ(øœŸš Õ(ýsHÁ)B%Á=CÂ%CÃC!ÃCÃC!ÃCÃ!D&Ã#D Ã4D&Ä D#Ä#D&cóT>•[TU]5 URURS9 g)NrÅ)ÚsuperrdrÕÚblock_on_close©r$Ú __class__s €r%rdÚForkingMixIn.server_close€s%ø€Ü ‰GÑ Ô "Ø × !Ñ !¨4×+>Ñ+>Ð !Ò ?r()rÉ)r…r†r‡rˆr‰rHrÉrËrärÕrKr8rSrdrŠÚ __classcell__©ræs@r%rr-s>ø†ÙCàˆØˆØˆ àˆà/4õ! òF $ò $ò )÷2 @ó @r(rcó>^•\rSrSrSrU4SjrSrSrSrSr U=r $)Ú_Threadsi…z* Joinable list of all non-daemon threads. cóh>•UR5 UR(ag[TU] U5 gr|)ÚreapÚdaemonrãÚappend)r$Úthreadræs €r%rïÚ_Threads.append‰s"ø€Ø � ‰ Œ Ø �=�=Ø Ü ‰‰�vÕr(có•/USSsUSS&nU$r|r+)r$Úresults r%Úpop_allÚ_Threads.pop_all�s€Ø˜d¡1˜gˆˆ‰Qˆ�؈ r(cóR•UR5HnUR5 M gr|)rôÚjoin©r$rðs r%r÷Ú _Threads.join“s€Ø—l‘l–nˆFØ �K‰KŽMò%r(có•SU5USS&g)Nc3óR# •UHoR5(dMUv• M g7fr|)Úis_alive)Ú.0rðs r%Ú Ú _Threads.reap..˜sé€ÐBª˜f·±×0A—6‘6ªùs‚'ž 'r+r,s r%ríÚ _Threads.reap—s€ÙB©ÓBˆ‰Q‰r(r+) r…r†r‡rˆr‰rïrôr÷rírŠrèrés@r%rërë…s#ø†ñõò ò÷CðCr(rëcó$•\rSrSrSrSrSrSrg)Ú _NoThreadsi›z! Degenerate version of _Threads. có•gr|r+røs r%rïÚ_NoThreads.appendŸó€Ø r(có•gr|r+r,s r%r÷Ú_NoThreads.join¢rr(r+N)r…r†r‡rˆr‰rïr÷rŠr+r(r%rr›s†ñò õ r(rcóN^•\rSrSrSrSrSr\"5rSr Sr U4Sjr Sr U=r $) r i¦z4Mix-in class to handle each request in a new thread.FTcó¸•URX5 URU5 g![a URX5 N/f=f!URU5 f=f)zWSame as in BaseServer but as a thread. In addition, exception handling is done here. N)r`rTrUrVrWs r%Úprocess_request_threadÚ%ThreadingMixIn.process_request_thread²sU€ð  +Ø × Ñ  Ô 8ð × !Ñ ! 'Õ *øôó 7Ø × Ñ ˜gÖ 6ð 7ûð × !Ñ ! 'Õ *ús!‚%¥AÁAÁAÁAÁAcó$•UR(a#[U5RS[55 [R "UR X4S9nURUlURRU5 UR5 g)z*Start a new thread to process the request.Ú_threads)Útargetr€N) räÚvarsÚ setdefaultrër ÚThreadr Údaemon_threadsrîr rïÚstart)r$rXrYÚts r%rSÚThreadingMixIn.process_request¿sg€à × × Ü �‹J× !Ñ ! *¬h«jÔ 9Ü × Ò  d×&AÑ&AØ%,Ð$=ñ ?ˆà×&Ñ&ˆŒØ � ‰ ×јQÔØ �‰� r(cóV>•[TU]5 URR5 gr|)rãrdr r÷rås €r%rdÚThreadingMixIn.server_closeÉsø€Ü ‰ÑÔØ � ‰ ×ÑÕr(r+)r…r†r‡rˆr‰rrärr r rSrdrŠrèrés@r%r r ¦s/ø†Ù>ð€Nà€Nñ‹|€Hò +ò÷ór(r có•\rSrSrSrg)riÏr+N©r…r†r‡rˆrŠr+r(r%rrÏó†²Tr(rcó•\rSrSrSrg)riÐr+Nrr+r(r%rrÐrr(rcó•\rSrSrSrg)riÒr+Nrr+r(r%rrÒrr(rcó•\rSrSrSrg)r iÓr+Nrr+r(r%r r Órr(r có,•\rSrSr\R rSrg)ri×r+N©r…r†r‡rˆrFrrŽrŠr+r(r%rr×ó †ØŸ™‹r(rcó,•\rSrSr\R rSrg)riÚr+Nrr+r(r%rrÚr r(rcó•\rSrSrSrg)riÝr+Nrr+r(r%rrÝó†Âtr(rcó•\rSrSrSrg)rißr+Nrr+r(r%rrßó†Ê4r(rcó•\rSrSrSrg)riâr+Nrr+r(r%rrâr#r(có•\rSrSrSrg)riär+Nrr+r(r%rrär%r(có0•\rSrSrSrSrSrSrSrSr g) r iæayBase class for request handler classes. This class is instantiated for each request to be handled. The constructor sets the instance variables request, client_address and server, and then calls the handle() method. To implement a specific service, all you need to do is to derive a class which defines a handle() method. The handle() method can find the request as self.request, the client address as self.client_address, and the server (in case it needs access to per-server information) as self.server. Since a separate instance is created for each request, the handle() method can define other arbitrary instance variables. có´•XlX lX0lUR5 UR 5 UR 5 g!UR 5 f=fr|)rXrYÚserverÚsetupÚhandleÚfinish)r$rXrYr*s r%r&ÚBaseRequestHandler.__init__øs<€ØŒ Ø,ÔØŒ Ø � ‰ Œ ð Ø �K‰KŒMà �K‰K�MøˆD�K‰K�Mús ¤AÁAcó•gr|r+r,s r%r+ÚBaseRequestHandler.setuprr(có•gr|r+r,s r%r,ÚBaseRequestHandler.handlerr(có•gr|r+r,s r%r-ÚBaseRequestHandler.finishrr()rYrXr*N) r…r†r‡rˆr‰r&r+r,r-rŠr+r(r%r r æs†ñò ò ò õ r(r có4•\rSrSrSrSrSrSrSrSr Sr S r g) r iz4Define self.rfile and self.wfile for stream sockets.rÈrNFcó •URUlURb%URRUR5 UR(a9URR [ R[ RS5 URRSUR5Ul URS:Xa[UR5UlgURRSUR5Ulg)NTÚrbrÚwb)rXÚ connectionrHÚ settimeoutÚdisable_nagle_algorithmr™rFÚ IPPROTO_TCPÚ TCP_NODELAYÚmakefileÚrbufsizeÚrfileÚwbufsizeÚ _SocketWriterÚwfiler,s r%r+ÚStreamRequestHandler.setup)s°€ØŸ,™,ˆŒØ �<‰<Ñ #Ø �O‰O× &Ñ & t§|¡|Ô 4Ø × '× 'Ø �O‰O× &Ñ &¤v×'9Ñ'9Ü'-×'9Ñ'9¸4ô Aà—_‘_×-Ñ-¨d°D·M±MÓBˆŒ Ø �=‰=˜AÓ Ü& t§¡Ó7ˆD�JàŸ™×1Ñ1°$¸¿ ¹ ÓFˆD�Jr(có •URR(dURR5 URR 5 UR R 5 g![Ra NKf=fr|)rCÚclosedÚflushrFÚerrorr¦r@r,s r%r-ÚStreamRequestHandler.finish6s`€Ø�z‰z× × ð Ø— ‘ × Ñ Ô"ð � ‰ ×ÑÔØ � ‰ ×ÑÕøô —<‘<ó ñð ús�A,Á,BÂB)r9r@rC) r…r†r‡rˆr‰r?rArHr;r+r-rŠr+r(r%r r s+†á>ð€HØ€Hð€Gð$Ðò Gõ r(r có0•\rSrSrSrSrSrSrSrSr g) rBiAz~Simple writable BufferedIOBase implementation for a socket Does not hold data in a buffer, avoiding any need to call flush().có•Xlgr|©Ú_sock)r$Úsocks r%r&Ú_SocketWriter.__init__Fs€Ø� r(có•g)NTr+r,s r%ÚwritableÚ_SocketWriter.writableIs€Ør(cóœ•URRU5 [U5nURsSSS5 $!,(df  g=fr|)rMÚsendallÚ memoryviewÚnbytes)r$ÚbÚviews r%ÚwriteÚ_SocketWriter.writeLs.€Ø � ‰ ×ј1ÔÜ ˜Œ]˜dØ—;‘;÷�]�]ús § =½ A có6•URR5$r|)rMr©r,s r%r©Ú_SocketWriter.filenoQs€Ø�z‰z× Ñ Ó"Ð"r(rLN) r…r†r‡rˆr‰r&rQrYr©rŠr+r(r%rBrBAs†ñJòòòõ #r(rBcó$•\rSrSrSrSrSrSrg)r iTz6Define self.rfile and self.wfile for datagram sockets.cóˆ•SSKJn URuUlUlU"UR5UlU"5Ulg)Nr)ÚBytesIO)Úior_rXÚpacketrFr@rC)r$r_s r%r+ÚDatagramRequestHandler.setupXs0€ÝØ#'§<¡<Ñ ˆŒ �T”[Ù˜TŸ[™[Ó)ˆŒ Ù“Yˆ� r(có€•URRURR5UR5 gr|)rFÚsendtorCÚgetvaluerYr,s r%r-ÚDatagramRequestHandler.finish^s)€Ø � ‰ ×ј4Ÿ:™:×.Ñ.Ó0°$×2EÑ2EÕFr()rar@rFrCN)r…r†r‡rˆr‰r+r-rŠr+r(r%r r Ts†á@òõ Gr(r )'r‰Ú __version__rFr4rÌrvr r`rrJrÚ__all__r˜Úextendrr2ÚSelectSelectorrrrrÚlistrërr rrrr rrrrrrr r rBr r+r(r%Úrlsçðñvðt€ óÛÛ Û ÛÝÝ"ò 7€ñ ˆ2ˆv×ÑØ ‡N�NÒJÔKÙ ˆ6�9×ÑØ ‡N�Nò3ô4ñˆr�6×ÑØ�‰Ð1Ð3NÐOÔPñ ˆ9�n×%Ñ%Ø×,Ñ,�Oà×.Ñ.€O÷jñjôZE� ôEôP � ô ñ8 ˆ2ˆv×Ñ÷U@ñU@ôpCˆtôC÷, ñ ÷%ñ%ñP ˆ2ˆv×ÑÜ9˜<¨Ô9Ü9˜<¨Ô9ä9˜¨Ô9Ü9˜¨Ô9á ˆ6�9×Ñô(˜9ô(ô(˜Yô(ôL NÐ4DÔKäO nÐ6HÔOáˆr�6×ÑÜK lÐ4DÔKäO¨ Ð6HÔO÷# ñ# ô\+Ð-ô+ôZ#�Nô#ô& GÐ/õ Gr(