-í
‹H ?c       sÎ    d  Z  / 1 d k Z 2 d k Z 3 d k Z 4 d k Z 6 d k Z 7 d k l Z l Z l	 Z	 l
 Z
 l Z l Z l Z l Z : y ; e Wn < e j
 o = h  Z n X? d e i f d „  ƒ  YZ B d Z D d e d „ Z q 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 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.
N(   s   EALREADYs   EINPROGRESSs   EWOULDBLOCKs
   ECONNRESETs   ENOTCONNs	   ESHUTDOWNs   EINTRs   EISCONNs   ExitNowc      s   ? @ RS(   N(    (    (    (    s%   /mit/python/lib/python2.2/asyncore.pys   ExitNow? s   i    f0.0c    sc  D E | t j o F t } n G | o5H g  } g  } g  } I xe | i ƒ  DI ]T \ } } J | i	 ƒ  o K | i
 | ƒ n L | i ƒ  o M | i
 | ƒ n qO WN y( O t i | | | |  ƒ \ } } } Wn9 P t i j
 o' } Q | d t j o
 R ‚  n n XT t o U | G| G| GHn W x� | DW ]… } X y Y | | } Wn Z t j
 o [ q9n X] y ^ | i ƒ  Wn5 _ t j
 o ` t ‚ n a b | i ƒ  n Xq9Wd x� | Dd ]… } e y f | | } Wn g t j
 o h qÏn Xj y k | i ƒ  Wn5 l t j
 o m t ‚ n n o | i ƒ  n XqÏWn d  S(   Ni    (   s   maps   Nones
   socket_maps   rs   ws   es   itemss   fds   objs   readables   appends   writables   selects   timeouts   errors   errs   EINTRs   DEBUGs   KeyErrors   handle_read_events   ExitNows   handle_errors   handle_write_event(   s   timeouts   maps   es   ws   errs   rs   fds   obj(    (    s%   /mit/python/lib/python2.2/asyncore.pys   pollD sR   
 (

 	
 	c    sê  q r d  k  } s | t j o t t } n u |  t j	 o w t |  d ƒ }  n x | o‰y g  } z xŽ | i ƒ  Dz ]} \ } } { d } | | i ƒ  o } | i } n ~ | i ƒ  o  | | i B} n € | o � | i | | f ƒ n qv W‚ | i  | |  ƒ } ƒ xÍ | Dƒ ]Â \ } } „ y … | | } Wn † t j
 o ‡ qn X‰ yH Š | | i @o ‹ | i ƒ  n Œ | | i @o � | i ƒ  n Wn5 Ž t j
 o � t ‚ n � ‘ | i ƒ  n XqWn d  S(   Niè  i    (   s   polls   maps   Nones
   socket_maps   timeouts   ints   ls   itemss   fds   objs   flagss   readables   POLLINs   writables   POLLOUTs   appends   rs   KeyErrors   handle_read_events   handle_write_events   ExitNows   handle_error(   s   timeouts   maps   objs   ls   rs   fds   flagss   poll(    (    s%   /mit/python/lib/python2.2/asyncore.pys   poll2q s@   
	 	

 c    s*  “ • | t j o – t } n — |  t j	 o ™ t |  d ƒ }  n š t i ƒ  } › | oÆœ x‹ | i ƒ  Dœ ]z \ } } � d } ž | i ƒ  o Ÿ t i } n   | i ƒ  o ¡ | t i B} n ¢ | o £ | i | | ƒ n qp W¤ y ¥ | i |  ƒ } WnB ¦ t i j
 o0 } § | d t j o
 ¨ ‚  n © g  } n Xª xÍ | Dª ]Â \ } } « y ¬ | | } Wn ­ t j
 o ® qYn X° yH ± | t i @o ² | i ƒ  n ³ | t i @o ´ | i ƒ  n Wn5 µ t j
 o ¶ t ‚ n · ¸ | i ƒ  n XqYWn d  S(   Niè  i    (   s   maps   Nones
   socket_maps   timeouts   ints   selects   polls   pollsters   itemss   fds   objs   flagss   readables   POLLINs   writables   POLLOUTs   registers   rs   errors   errs   EINTRs   KeyErrors   handle_read_events   handle_write_events   ExitNows   handle_error(   s   timeouts   maps   objs   errs   pollsters   rs   fds   flags(    (    s%   /mit/python/lib/python2.2/asyncore.pys   poll3“ sH   
 	


 f30.0c    s‰   º ¼ | t j o ½ t } n ¿ | o- À t t d ƒ o Á t } n
 Ã t } n
 Å t	 } Ç x Ç | o È | |  | ƒ qf Wd  S(   Ns   poll(   s   maps   Nones
   socket_maps   use_polls   hasattrs   selects   poll3s   poll_funs   poll2s   polls   timeout(   s   timeouts   use_polls   maps   poll_fun(    (    s%   /mit/python/lib/python2.2/asyncore.pys   loopº s   
	 
s
   dispatcherc      sÃ  Ê Ë 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 0d „  Z 4d „  Z @d „  Z Jd „  Z Ud „  Z gd „  Z md „  Z td „  Z w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    s‹   Ñ Ò | on Ó |  i | | ƒ Õ |  i i d ƒ Ö d |  _ Ù y Ú | i ƒ  |  _ Wn Û t i	 j
 o
 Ý n Xn ß t
 |  _ d  S(   Ni    i   (   s   socks   selfs
   set_sockets   maps   sockets   setblockings	   connecteds   getpeernames   addrs   errors   None(   s   selfs   socks   map(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __init__Ñ s   
c    sú   á â |  i i d |  i i g } ã |  i o |  i o ä | i d ƒ n" å |  i o æ | i d ƒ n ç |  i t	 j	 oT è y é | i d |  i ƒ Wn/ ê t
 j
 o  ë | i t |  i ƒ ƒ n Xn ì d d i | ƒ t |  ƒ f Sd  S(   Ns   .s	   listenings	   connecteds   %s:%ds   <%s at %#x>s    (   s   selfs	   __class__s
   __module__s   __name__s   statuss	   acceptings   addrs   appends	   connecteds   Nones	   TypeErrors   reprs   joins   id(   s   selfs   status(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __repr__á s    "c    s4   î ð | t j o ñ t } n ò |  | |  i <d  S(   N(   s   maps   Nones
   socket_maps   selfs   _fileno(   s   selfs   map(    (    s%   /mit/python/lib/python2.2/asyncore.pys   add_channelî s   c    sQ   ô õ |  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   fd(    (    s%   /mit/python/lib/python2.2/asyncore.pys   del_channelô s
   c    sf   ü ý | | 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   type(    (    s%   /mit/python/lib/python2.2/asyncore.pys   create_socketü s
   c    s5   | |  _ | i ƒ  |  _ |  i | ƒ d  S(   N(   s   socks   selfs   sockets   filenos   _filenos   add_channels   map(   s   selfs   socks   map(    (    s%   /mit/python/lib/python2.2/asyncore.pys
   set_sockets   c    sk   	yB |  i i t i t i |  i i t i t i ƒ d Bƒ Wn t i j
 o
 n Xd  S(   Ni   (   s   selfs   sockets
   setsockopts
   SOL_SOCKETs   SO_REUSEADDRs
   getsockopts   error(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   set_reuse_addr	s   c    s   d Sd  S(   Ni   (    (   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   readables   s   macc    s    !|  i Sd  S(   N(   s   selfs	   accepting(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   writable s   c    s   #$d Sd  S(   Ni   (    (   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   writable#s   c    sS   *+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   num(    (    s%   /mit/python/lib/python2.2/asyncore.pys   listen*s    c    s&   01| |  _  2|  i i | ƒ Sd  S(   N(   s   addrs   selfs   sockets   bind(   s   selfs   addr(    (    s%   /mit/python/lib/python2.2/asyncore.pys   bind0s   c    sš   45d |  _ 6|  i i | ƒ } 7| t t t f j o 8d  Sn 9| d t	 f j o) :| |  _
 ;d |  _ <|  i ƒ  n >t i | ‚ d  S(   Ni    i   (   s   selfs	   connecteds   sockets
   connect_exs   addresss   errs   EINPROGRESSs   EALREADYs   EWOULDBLOCKs   EISCONNs   addrs   handle_connects   error(   s   selfs   addresss   err(    (    s%   /mit/python/lib/python2.2/asyncore.pys   connect4s   c    s{   @Ay) B|  i i ƒ  \ } } C| | f SWnE Dt i j
 o3 } E| d t j o Fn Ht i | ‚ n Xd  S(   Ni    (   s   selfs   sockets   accepts   conns   addrs   errors   whys   EWOULDBLOCK(   s   selfs   whys   conns   addr(    (    s%   /mit/python/lib/python2.2/asyncore.pys   accept@s   c    s}   JKy  L|  i i | ƒ } M| SWnP Nt i j
 o> } O| d t j o Pd Sn Rt i | ‚ Sd Sn Xd  S(   Ni    (   s   selfs   sockets   sends   datas   results   errors   whys   EWOULDBLOCK(   s   selfs   datas   whys   result(    (    s%   /mit/python/lib/python2.2/asyncore.pys   sendJs   c    s¯   UVyC W|  i i | ƒ } X| o [|  i ƒ  \d Sn ^| SWn_ _t i j
 oM } a| d t t	 t
 g j o b|  i ƒ  cd Sn e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   why(    (    s%   /mit/python/lib/python2.2/asyncore.pys   recvUs   c    s$   gh|  i ƒ  i|  i i ƒ  d  S(   N(   s   selfs   del_channels   sockets   close(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   closegs   c    s   mnt  |  i | ƒ Sd  S(   N(   s   getattrs   selfs   sockets   attr(   s   selfs   attr(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __getattr__ms   c    s$   tut  i i d t | ƒ ƒ d  S(   Ns   log: %s
(   s   syss   stderrs   writes   strs   message(   s   selfs   message(    (    s%   /mit/python/lib/python2.2/asyncore.pys   logts   s   infoc    s4   wxt  p
 | d j o yd | | f GHn d  S(   Ns   infos   %s: %s(   s	   __debug__s   types   message(   s   selfs   messages   type(    (    s%   /mit/python/lib/python2.2/asyncore.pys   log_infows   c    sˆ   {||  i o/ |  i o €d |  _ n �|  i ƒ  nF ‚|  i o* ƒ|  i ƒ  „d |  _ …|  i ƒ  n ‡|  i ƒ  d  S(   Ni   (   s   selfs	   acceptings	   connecteds   handle_accepts   handle_connects   handle_read(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_read_event{s   c    s?   ‰‹|  i o Œ|  i ƒ  �d |  _ n Ž|  i ƒ  d  S(   Ni   (   s   selfs	   connecteds   handle_connects   handle_write(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_write_event‰s   c    s   �‘|  i ƒ  d  S(   N(   s   selfs   handle_expt(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_expt_event�s   c    sˆ   “”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   nils   ts   vs   tbinfos   reprs   selfs	   self_reprs   ids   log_infos   close(   s   selfs   tbinfos   nils   vs	   self_reprs   t(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_error“s   
c    s   §¨|  i d d ƒ d  S(   Ns   unhandled exceptions   warning(   s   selfs   log_info(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_expt§s   c    s   ª«|  i d d ƒ d  S(   Ns   unhandled read events   warning(   s   selfs   log_info(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_readªs   c    s   ­®|  i d d ƒ d  S(   Ns   unhandled write events   warning(   s   selfs   log_info(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_write­s   c    s   °±|  i d d ƒ d  S(   Ns   unhandled connect events   warning(   s   selfs   log_info(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_connect°s   c    s   ³´|  i d d ƒ d  S(   Ns   unhandled accept events   warning(   s   selfs   log_info(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_accept³s   c    s'   ¶·|  i d d ƒ ¸|  i ƒ  d  S(   Ns   unhandled close events   warning(   s   selfs   log_infos   close(   s   self(    (    s%   /mit/python/lib/python2.2/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.2/asyncore.pys
   dispatcherÊ sH   					
s   dispatcher_with_sendc      sD   ¿À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   sock(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __init__Às   c    s?   ÄÅd } Æt i |  |  i d  ƒ } Ç|  i | |  _ d  S(   Ni    i   (   s   num_sents
   dispatchers   sends   selfs
   out_buffer(   s   selfs   num_sent(    (    s%   /mit/python/lib/python2.2/asyncore.pys   initiate_sendÄs   	c    s   ÉÊ|  i ƒ  d  S(   N(   s   selfs   initiate_send(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   handle_writeÉs   c    s"   ÌÍ|  i p t |  i ƒ Sd  S(   N(   s   selfs	   connecteds   lens
   out_buffer(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   writableÌs   c    sR   ÏÐ|  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   data(    (    s%   /mit/python/lib/python2.2/asyncore.pys   sendÏs   (   s   Nones   __init__s   initiate_sends   handle_writes   writables   send(    (    (    s%   /mit/python/lib/python2.2/asyncore.pys   dispatcher_with_send¿s
   c     sî   ÙÚt  i ƒ  \ } } } Ûg  }  Üxb Üd oW Ý|  i | i i i	 | i i i
 t | i ƒ f ƒ â| i } ã| o äPn q* Wç~ é|  d \ } } } êd d i t d „  |  ƒ ƒ d } ë| | | f | | | f Sd  S(   Ni   iÿÿÿÿs   [s   ] [c    s   êd i  |  ƒ S(   Ns   |(   s   joins   x(   s   x(    (    s%   /mit/python/lib/python2.2/asyncore.pys   <lambda>ê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   joins   maps   info(   s   tbinfos   infos   functions   ts   files   vs   lines   tb(    (    s%   /mit/python/lib/python2.2/asyncore.pys   compact_tracebackÙs   	 
4&c    s^   íî|  t j o ït }  n ðx' |  i ƒ  Dð] } ñ| i i ƒ  q0 Wò|  i ƒ  d  S(   N(   s   maps   Nones
   socket_maps   valuess   xs   sockets   closes   clear(   s   maps   x(    (    s%   /mit/python/lib/python2.2/asyncore.pys	   close_allís    	s   posixs   file_wrapperc      sS   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   fd(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __init__s   c    s$   t  t i |  i f | ƒ Sd  S(   N(   s   applys   oss   reads   selfs   fds   args(   s   selfs   args(    (    s%   /mit/python/lib/python2.2/asyncore.pys   recvs   c    s$   t  t i |  i f | ƒ Sd  S(   N(   s   applys   oss   writes   selfs   fds   args(   s   selfs   args(    (    s%   /mit/python/lib/python2.2/asyncore.pys   sends   c    s   t  i |  i ƒ Sd  S(   N(   s   oss   closes   selfs   fd(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   closes   c    s   |  i Sd  S(   N(   s   selfs   fd(   s   self(    (    s%   /mit/python/lib/python2.2/asyncore.pys   filenos   (   s   __init__s   recvs   sends   reads   writes   closes   fileno(    (    (    s%   /mit/python/lib/python2.2/asyncore.pys   file_wrappers   		s   file_dispatcherc      s   d „  Z  $d „  Z RS(   Nc    sw   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   F_GETFLs   flagss   oss
   O_NONBLOCKs   F_SETFLs   set_file(   s   selfs   fds   flags(    (    s%   /mit/python/lib/python2.2/asyncore.pys   __init__s   c    s2   $%| |  _ &t | ƒ |  _ '|  i ƒ  d  S(   N(   s   fds   selfs   _filenos   file_wrappers   sockets   add_channel(   s   selfs   fd(    (    s%   /mit/python/lib/python2.2/asyncore.pys   set_file$s   (   s   __init__s   set_file(    (    (    s%   /mit/python/lib/python2.2/asyncore.pys   file_dispatchers   	(!   s   __doc__s
   exceptionss   selects   sockets   syss   oss   errnos   EALREADYs   EINPROGRESSs   EWOULDBLOCKs
   ECONNRESETs   ENOTCONNs	   ESHUTDOWNs   EINTRs   EISCONNs
   socket_maps	   NameErrors	   Exceptions   ExitNows   DEBUGs   Nones   polls   poll2s   poll3s   loops
   dispatchers   dispatcher_with_sends   compact_tracebacks	   close_alls   names   fcntls   file_wrappers   file_dispatcher(   s   fcntls   ENOTCONNs	   ESHUTDOWNs   dispatcher_with_sends   ExitNows   syss	   close_alls   compact_tracebacks   EINTRs   DEBUGs   polls
   dispatchers   selects   EISCONNs   file_wrappers   sockets
   ECONNRESETs   file_dispatchers   poll2s   poll3s   EINPROGRESSs   EWOULDBLOCKs
   socket_maps
   exceptionss   EALREADYs   oss   loop(    (    s%   /mit/python/lib/python2.2/asyncore.pys   ?/ s2   :	-"'õ