‡Æ
ÃMö9c       s¬  d  Z  d k Z d k Z d k Z d k Z d k Z d k Z e i d j o( d Z d Z	 d Z
 d Z d Z d Z n, d	 k l
 Z
 l	 Z	 l Z l Z l Z l Z y e Wn e j
 o h  Z n Xd
 e i f d „  ƒ  YZ d Z d e d „ Z d e d „ Z d d e d „ Z d f  d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d „ Z d k Z e i d j o? d k Z d k Z d f  d „  ƒ  YZ d e f d „  ƒ  YZ n d S(   s¤  Basic infrastructure for asynchronous socket service clients and servers.

There are only two ways to have a program on a single processor do "more
than one thing at a time".  Multi-threaded programming is the simplest and 
most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however. 

If your operating system supports the select() system call in its I/O 
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking
place in the "background."  Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap. 
Ns   nti3'  i4'  i5'  iF'  iI'  iJ'  (   s   EALREADYs   EINPROGRESSs   EWOULDBLOCKs
   ECONNRESETs   ENOTCONNs	   ESHUTDOWNs   ExitNowc      s   RS(   N(    (    s%   /mit/python/lib/python2.0/asyncore.pys   ExitNowG s    i    c    s®  | t j o
 t } n | oŒg  } g  } g  } xX | i ƒ  d rH \ } } | i	 ƒ  o | i
 | ƒ n | i ƒ  o | i
 | ƒ n q? Wt i | | | |  ƒ \ } } } t o | G| G| GHn xn | d rd } yH | | } y | i ƒ  Wn) t j
 o t ‚ n | i ƒ  n XWn t j
 o n XqÍ Wxn | d rd } yH | | } y | i ƒ  Wn) t j
 o t ‚ n | i ƒ  n XWn t j
 o n Xq>Wn d  S(   Ni    (   s   maps   Nones
   socket_maps   rs   ws   es   itemss   fds   objs   readables   appends   writables   selects   timeouts   DEBUGs   handle_read_events   ExitNows   handle_errors   KeyErrors   handle_write_event(   s   timeouts   maps   rs   ws   es   fds   objs%   /mit/python/lib/python2.0/asyncore.pys   pollL sL     
 !	 

		 

f0.0c    sw  d  k  } | t j o
 t } n t |  d ƒ }  | o<g  } xx | i ƒ  d rh \ } } d } | i ƒ  o | i } n | i ƒ  o | | i B} n | o | i | | f ƒ n qL W| i  | |  ƒ } x¢ | d r˜ \ } } yv | | } y< | | i @o | i ƒ  n | | i @o | i ƒ  n Wn) t j
 o t ‚ n | i ƒ  n XWn t j
 o n XqÓ Wn d  S(   Niè  i    (   s   polls   maps   Nones
   socket_maps   ints   timeouts   ls   itemss   fds   objs   flagss   readables   POLLINs   writables   POLLOUTs   appends   rs   handle_read_events   handle_write_events   ExitNows   handle_errors   KeyError(   s   timeouts   maps   polls   ls   fds   objs   flagss   rs%   /mit/python/lib/python2.0/asyncore.pys   poll2t s>    	
 	 

c    sN   | o
 t } n t } | t j o
 t } n x | o | |  | ƒ q1 Wd  S(   N(   s   use_polls   poll2s   poll_funs   polls   maps   Nones
   socket_maps   timeout(   s   timeouts   use_polls   maps   poll_funs%   /mit/python/lib/python2.0/asyncore.pys   loop” s    

 f30.0s
   dispatcherc      sT  d Z  d Z d Z d Z e Z e e d „ Z d „  Z e d „ Z e d „ Z	 d „  Z
 e d „ Z d „  Z d	 „  Z e i d
 j o d „  Z n
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d  „  Z# d! „  Z$ RS("   Ni    c    s8   | o- |  i | | ƒ |  i i d ƒ d |  _ n d  S(   Ni    i   (   s   socks   selfs
   set_sockets   maps   sockets   setblockings	   connected(   s   selfs   socks   maps%   /mit/python/lib/python2.0/asyncore.pys   __init__¨ s    c    sÚ   y• g  } |  i o |  i o | i d ƒ n |  i o | i d ƒ n |  i o | i d |  i ƒ n d |  i i t i	 | d ƒ t
 |  ƒ f SWn> y t |  i ƒ } Wn d } n Xd t
 |  ƒ | f Sn Xd  S(   Ns	   listenings	   connecteds   %s:%ds   <%s %s at %x>s    s   no self.addr!s3   <__repr__ (self) failed for object at %x (addr=%s)>(   s   statuss   selfs	   acceptings   addrs   appends	   connecteds	   __class__s   __name__s   strings   joins   ids   reprs   ar(   s   selfs   statuss   ars%   /mit/python/lib/python2.0/asyncore.pys   __repr__¯ s    

-
c    s(   | t j o
 t } n |  | |  i <d  S(   N(   s   maps   Nones
   socket_maps   selfs   _fileno(   s   selfs   maps%   /mit/python/lib/python2.0/asyncore.pys   add_channelÅ s    
c    s?   |  i } | t j o
 t } n | i | ƒ o | | =n d  S(   N(   s   selfs   _filenos   fds   maps   Nones
   socket_maps   has_key(   s   selfs   maps   fds%   /mit/python/lib/python2.0/asyncore.pys   del_channelË s
    	
c    sT   | | f |  _ t i | | ƒ |  _ |  i i d ƒ |  i i ƒ  |  _ |  i ƒ  d  S(   Ni    (	   s   familys   types   selfs   family_and_types   sockets   setblockings   filenos   _filenos   add_channel(   s   selfs   familys   types%   /mit/python/lib/python2.0/asyncore.pys   create_socketÓ s
    c    s-   | |  i d <| i ƒ  |  _ |  i | ƒ d  S(   Ns   socket(   s   socks   selfs   __dict__s   filenos   _filenos   add_channels   map(   s   selfs   socks   maps%   /mit/python/lib/python2.0/asyncore.pys
   set_socketÚ s    c    sG   y9 |  i i t i t i |  i i t i t i ƒ d Bƒ Wn n Xd  S(   Ni   (   s   selfs   sockets
   setsockopts
   SOL_SOCKETs   SO_REUSEADDRs
   getsockopt(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   set_reuse_addrß s
    $c    s   d Sd  S(   Ni   (    (   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   readableï s    s   macc    s   |  i Sd  S(   N(   s   selfs	   accepting(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   writableõ s    c    s   d Sd  S(   Ni   (    (   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   writableø s    c    sD   d |  _ t i d j o
 | d j o
 d } n |  i i | ƒ Sd  S(   Ni   s   nti   (   s   selfs	   acceptings   oss   names   nums   sockets   listen(   s   selfs   nums%   /mit/python/lib/python2.0/asyncore.pys   listenÿ s    	
c    s   | |  _  |  i i | ƒ Sd  S(   N(   s   addrs   selfs   sockets   bind(   s   selfs   addrs%   /mit/python/lib/python2.0/asyncore.pys   binds    	c    s}   d |  _ y |  i i | ƒ WnF t i j
 o7 } | d t t t	 f j o d  Sn t i | ‚ n Xd |  _ |  i
 ƒ  d  S(   Ni    i   (   s   selfs	   connecteds   sockets   connects   addresss   errors   whys   EINPROGRESSs   EALREADYs   EWOULDBLOCKs   handle_connect(   s   selfs   addresss   whys%   /mit/python/lib/python2.0/asyncore.pys   connect	s    		c    sc   y# |  i i ƒ  \ } } | | f SWn9 t i j
 o* } | d t j o n t i | ‚ n Xd  S(   Ni    (   s   selfs   sockets   accepts   conns   addrs   errors   whys   EWOULDBLOCK(   s   selfs   conns   addrs   whys%   /mit/python/lib/python2.0/asyncore.pys   accepts    c    sb   y |  i i | ƒ } | SWnA t i j
 o2 } | d t j o d Sn t i | ‚ d Sn Xd  S(   Ni    (   s   selfs   sockets   sends   datas   results   errors   whys   EWOULDBLOCK(   s   selfs   datas   results   whys%   /mit/python/lib/python2.0/asyncore.pys   sends    c    s‹   y4 |  i i | ƒ } | o |  i ƒ  d Sn | SWnP t i j
 oA } | d t t	 t
 g j o |  i ƒ  d Sn t i | ‚ n Xd  S(   Ns    i    (   s   selfs   sockets   recvs   buffer_sizes   datas   handle_closes   errors   whys
   ECONNRESETs   ENOTCONNs	   ESHUTDOWN(   s   selfs   buffer_sizes   datas   whys%   /mit/python/lib/python2.0/asyncore.pys   recv*s    

c    s   |  i ƒ  |  i i ƒ  d  S(   N(   s   selfs   del_channels   sockets   close(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   close<s    
c    s   t  |  i | ƒ Sd  S(   N(   s   getattrs   selfs   sockets   attr(   s   selfs   attrs%   /mit/python/lib/python2.0/asyncore.pys   __getattr__Bs    c    s   t  i i d t | ƒ ƒ d  S(   Ns   log: %s
(   s   syss   stderrs   writes   strs   message(   s   selfs   messages%   /mit/python/lib/python2.0/asyncore.pys   logIs    c    s+   t  p
 | d j o d | | f GHn d  S(   Ns   infos   %s: %s(   s	   __debug__s   types   message(   s   selfs   messages   types%   /mit/python/lib/python2.0/asyncore.pys   log_infoLs    s   infoc    sj   |  i o& |  i o d |  _ n |  i ƒ  n7 |  i o! |  i ƒ  d |  _ |  i ƒ  n |  i ƒ  d  S(   Ni   (   s   selfs	   acceptings	   connecteds   handle_accepts   handle_connects   handle_read(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_read_eventPs    

	c    s0   |  i o |  i ƒ  d |  _ n |  i ƒ  d  S(   Ni   (   s   selfs	   connecteds   handle_connects   handle_write(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_write_event^s    
c    s   |  i ƒ  d  S(   N(   s   selfs   handle_expt(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_expt_eventes    c    sv   t  ƒ  \ \ } } } } } } y t |  ƒ } Wn d t
 |  ƒ } n X|  i d | | | | f d ƒ |  i ƒ  d  S(   Ns*   <__repr__ (self) failed for object at %0x>s:   uncaptured python exception, closing channel %s (%s:%s %s)s   error(   s   compact_tracebacks   files   funs   lines   ts   vs   tbinfos   reprs   selfs	   self_reprs   ids   log_infos   close(   s   selfs   files   funs   lines   ts   vs   tbinfos	   self_reprs%   /mit/python/lib/python2.0/asyncore.pys   handle_errorhs    c    s   |  i d d ƒ d  S(   Ns   unhandled exceptions   warning(   s   selfs   log_info(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_expt|s    c    s   |  i d d ƒ d  S(   Ns   unhandled read events   warning(   s   selfs   log_info(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_reads    c    s   |  i d d ƒ d  S(   Ns   unhandled write events   warning(   s   selfs   log_info(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_write‚s    c    s   |  i d d ƒ d  S(   Ns   unhandled connect events   warning(   s   selfs   log_info(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_connect…s    c    s   |  i d d ƒ d  S(   Ns   unhandled accept events   warning(   s   selfs   log_info(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_acceptˆs    c    s   |  i d d ƒ |  i ƒ  d  S(   Ns   unhandled close events   warning(   s   selfs   log_infos   close(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_close‹s    (%   s   debugs	   connecteds	   acceptings   closings   Nones   addrs   __init__s   __repr__s   add_channels   del_channels   create_sockets
   set_sockets   set_reuse_addrs   readables   oss   names   writables   listens   binds   connects   accepts   sends   recvs   closes   __getattr__s   logs   log_infos   handle_read_events   handle_write_events   handle_expt_events   handle_errors   handle_expts   handle_reads   handle_writes   handle_connects   handle_accepts   handle_close(    s%   /mit/python/lib/python2.0/asyncore.pys
   dispatcher¡ sH    									
														s   dispatcher_with_sendc      s2   e  d „ Z d „  Z d „  Z d „  Z d „  Z RS(   Nc    s   t  i |  | ƒ d |  _ d  S(   Ns    (   s
   dispatchers   __init__s   selfs   socks
   out_buffer(   s   selfs   socks%   /mit/python/lib/python2.0/asyncore.pys   __init__•s    c    s3   d } t i |  |  i d  ƒ } |  i | |  _ d  S(   Ni    i   (   s   num_sents
   dispatchers   sends   selfs
   out_buffer(   s   selfs   num_sents%   /mit/python/lib/python2.0/asyncore.pys   initiate_send™s    c    s   |  i ƒ  d  S(   N(   s   selfs   initiate_send(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   handle_writežs    c    s   |  i p t |  i ƒ Sd  S(   N(   s   selfs	   connecteds   lens
   out_buffer(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   writable¡s    c    sC   |  i o |  i d t | ƒ ƒ n |  i | |  _ |  i ƒ  d  S(   Ns
   sending %s(   s   selfs   debugs   log_infos   reprs   datas
   out_buffers   initiate_send(   s   selfs   datas%   /mit/python/lib/python2.0/asyncore.pys   send¤s    
(   s   Nones   __init__s   initiate_sends   handle_writes   writables   send(    s%   /mit/python/lib/python2.0/asyncore.pys   dispatcher_with_send”s
    			c     sË   t  i ƒ  \ }  } } g  } xS d oK | i | i i i	 | i i i
 t | i ƒ f ƒ | i } | o Pn q W~ | d \ } } } d t i t d „  | ƒ d ƒ d } | | | f |  | | f Sd  S(   Ni   s   [c    s   t  i |  d ƒ S(   Ns   |(   s   strings   joins   x(   s   xs%   /mit/python/lib/python2.0/asyncore.pys   <lambda>Ás    s   ] [s   ](   s   syss   exc_infos   ts   vs   tbs   tbinfos   appends   tb_frames   f_codes   co_filenames   co_names   strs	   tb_linenos   tb_nexts   files   functions   lines   strings   joins   maps   info(   s   ts   vs   tbs   tbinfos   files   functions   lines   infos%   /mit/python/lib/python2.0/asyncore.pys   compact_traceback®s     1	
c    sK   |  t j o
 t }  n x# |  i ƒ  d r } | i i ƒ  q& W|  i ƒ  d  S(   Ni    (   s   maps   Nones
   socket_maps   valuess   xs   sockets   closes   clear(   s   maps   xs%   /mit/python/lib/python2.0/asyncore.pys	   close_allÈs    
 s   posixs   file_wrapperc      s;   d „  Z  d „  Z d „  Z e Z e Z d „  Z d „  Z RS(   Nc    s   | |  _  d  S(   N(   s   fds   self(   s   selfs   fds%   /mit/python/lib/python2.0/asyncore.pys   __init__äs    c    s   t  t i |  i f | ƒ Sd  S(   N(   s   applys   oss   reads   selfs   fds   args(   s   selfs   argss%   /mit/python/lib/python2.0/asyncore.pys   recvçs    c    s   t  t i |  i f | ƒ Sd  S(   N(   s   applys   oss   writes   selfs   fds   args(   s   selfs   argss%   /mit/python/lib/python2.0/asyncore.pys   sendês    c    s   t  i |  i ƒ Sd  S(   N(   s   oss   closes   selfs   fd(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   closeðs    c    s   |  i Sd  S(   N(   s   selfs   fd(   s   selfs%   /mit/python/lib/python2.0/asyncore.pys   filenoós    (   s   __init__s   recvs   sends   reads   writes   closes   fileno(    s%   /mit/python/lib/python2.0/asyncore.pys   file_wrapperás    				s   file_dispatcherc      s   d „  Z  d „  Z RS(   Nc    sb   t  i |  ƒ d |  _ t i | t i d ƒ } | t i	 B} t i | t i
 | ƒ |  i | ƒ d  S(   Ni   i    (   s
   dispatchers   __init__s   selfs	   connecteds   fcntls   fds   FCNTLs   F_GETFLs   flagss
   O_NONBLOCKs   F_SETFLs   set_file(   s   selfs   fds   flagss%   /mit/python/lib/python2.0/asyncore.pys   __init__÷s    	c    s&   | |  _ t | ƒ |  _ |  i ƒ  d  S(   N(   s   fds   selfs   _filenos   file_wrappers   sockets   add_channel(   s   selfs   fds%   /mit/python/lib/python2.0/asyncore.pys   set_file s    	(   s   __init__s   set_file(    s%   /mit/python/lib/python2.0/asyncore.pys   file_dispatcherös    		(    s   __doc__s
   exceptionss   selects   sockets   strings   syss   oss   names   EWOULDBLOCKs   EINPROGRESSs   EALREADYs
   ECONNRESETs   ENOTCONNs	   ESHUTDOWNs   errnos
   socket_maps	   NameErrors	   Exceptions   ExitNows   DEBUGs   Nones   polls   poll2s   loops
   dispatchers   dispatcher_with_sends   compact_tracebacks	   close_alls   fcntls   FCNTLs   file_wrappers   file_dispatcher(    s%   /mit/python/lib/python2.0/asyncore.pys   ?/ sB   						
+( ó				