Ñò »ÏâIc@sdZddkZdefd„ƒYZdefd„ƒYZdefd„ƒYZd „Zd d „Zd „Zd „Z dS(sAdapt an HTTP server.iÿÿÿÿNt ServerAdaptercBsneZdZd d d„Zd„Zd„Zd„Zde_d„Z d„Z d„Z d e _d „Z RS( s»Adapter for an HTTP server. If you need to start more than one HTTP server (to serve on multiple ports, or protocols, etc.), you can manually register each one and then start them all with bus.start: s1 = ServerAdapter(bus, MyWSGIServer(host='0.0.0.0', port=80)) s2 = ServerAdapter(bus, another.HTTPServer(host='127.0.0.1', SSL=True)) s1.subscribe() s2.subscribe() bus.start() cCs1||_||_||_d|_t|_dS(N(tbust httpservert bind_addrtNonet interrupttFalsetrunning(tselfRRR((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyt__init__s     cCs0|iid|iƒ|iid|iƒdS(Ntstarttstop(Rt subscribeR R (R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR scCs0|iid|iƒ|iid|iƒdS(NR R (Rt unsubscribeR R (R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR scCst|itƒo#|i\}}d||f}nd|i}|io|iid|ƒdSd|_|ipt dƒ‚nt|itƒot |iŒnddk }|i d|i ƒ}|id|iƒƒ|iƒ|iƒt|_|iid |ƒdS( sStart the HTTP server.s%s:%sssocket file: %ssAlready serving on %sNs No HTTP server has been created.iÿÿÿÿttargets HTTPServer s Serving on %s(t isinstanceRttupleRRtlogRRRt ValueErrortwait_for_free_portt threadingtThreadt_start_http_threadtsetNametgetNameR twaittTrue(Rthosttportton_whatRtt((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR #s&        iKcCsáy|iiƒWnÉtj o/}|iidƒ||_|iiƒntj o2}|iidƒ||_|iiƒ‚nSddk}|i ƒd|_|iiddt dd ƒ|iiƒ‚nXdS( sHTTP servers MUST be running in new threads, so that the main thread persists to receive KeyboardInterrupt's. If an exception is raised in the httpserver's thread then it's trapped here, and the bus (and therefore our httpserver) are shut down. s' hit: shutting down HTTP servers,SystemExit raised: shutting down HTTP serveriÿÿÿÿNis#Error in HTTP server: shutting downt tracebacktleveli(( RR tKeyboardInterruptRRRtexitt SystemExittsystexc_infoR(RtexcR$((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyRAs$      cCsyx?t|idtƒp(|io |i‚ntidƒqWt|itƒo |i\}}t ||ƒndS(s8Wait until the HTTP server is ready to receive requests.treadygš™™™™™¹?N( tgetattrRRRttimetsleepRRRtwait_for_occupied_port(RRR((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR[s  cCsz|ioU|iiƒt|itƒot|iŒnt|_|ii d|iƒn|ii d|iƒdS(sStop the HTTP server.sHTTP Server %s shut downs HTTP Server %s already shut downN( RRR RRRRRRR(R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR gs   icCs|iƒ|iƒdS(sRestart the HTTP server.N(R R (R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pytrestartus N( t__name__t __module__t__doc__RR R R R tpriorityRRR R,(((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyRs       tFlupFCGIServercBs)eZdZd„Zd„Zd„ZRS(s*Adapter for a flup.server.fcgi.WSGIServer.cOs||_||_t|_dS(N(targstkwargsRR'(RR2R3((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR ~s  cCs]ddkl}||i|iŽ|_d„|i_g|i_t|_|ii ƒdS(sStart the FCGI server.iÿÿÿÿ(t WSGIServercSsdS(N(R(((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyt’sN( tflup.server.fcgiR4R2R3t fcgiservert_installSignalHandlerst_oldSIGsRR'trun(RR4((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR ƒs    cCs1t|i_|iii|ii_t|_dS(sStop the HTTP server.N(RR7t _keepGoingt _threadPoolt _idleCounttmaxSpareR'(R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR —s (R-R.R/R R R (((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR1{s  tFlupSCGIServercBs)eZdZd„Zd„Zd„ZRS(s*Adapter for a flup.server.scgi.WSGIServer.cOs||_||_t|_dS(N(R2R3RR'(RR2R3((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR £s  cCs]ddkl}||i|iŽ|_d„|i_g|i_t|_|ii ƒdS(sStart the SCGI server.iÿÿÿÿ(R4cSsdS(N(R(((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR5·sN( tflup.server.scgiR4R2R3t scgiserverR8R9RR'R:(RR4((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR ¨s    cCs(t|_t|i_d|ii_dS(sStop the HTTP server.iN(RR'RAR;R<R>(R((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR ¼s  (R-R.R/R R R (((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR? s  cCs(|djodS|djodS|S(sDReturn the host on which a client can connect to the given listener.s0.0.0.0s 127.0.0.1s::s::1((t server_host((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyt client_hostÅs   gð?c Cs|ptdƒ‚nt|ƒ}t|ƒ}ddk}xÔ|i|||i|iƒD]´}|\}}}}} d} ye|i|||ƒ} | i|ƒ| i ||fƒ| i ƒt dt |ƒt |ƒfƒ‚WqZ|i j o| o| i ƒqqZXqZWdS(s?Raise an error if the given port is not free on the given host.s*Host values of '' or None are not allowed.iÿÿÿÿNsTPort %s is in use on %s; perhaps the previous httpserver did not shut down properly.(RRCtinttsockett getaddrinfot AF_UNSPECt SOCK_STREAMRt settimeouttconnecttclosetIOErrortreprterror( RRttimeoutREtrestaftsocktypetprotot canonnametsats((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyt check_portÏs(       c Cs†|ptdƒ‚nxRtdƒD]D}yt||ddƒWn tj otidƒq$XdSq$Wtd||fƒ‚dS(s;Wait for the specified port to become free (drop requests).s*Host values of '' or None are not allowed.i2ROgš™™™™™¹?NsPort %r not free on %r(RtxrangeRWRLR)R*(RRttrial((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyRìs cCs}|ptdƒ‚nxItdƒD];}yt||ƒWntj odSXtidƒq$Wtd||fƒ‚dS(s@Wait for the specified port to become active (receive requests).s*Host values of '' or None are not allowed.i2Ngš™™™™™¹?sPort %r not bound on %r(RRXRWRLR)R*(RRRY((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyR+ýs ( R/R)tobjectRR1R?RCRWRR+(((s>/usr/lib/python2.6/vendor-packages/cherrypy/process/servers.pyts u%%