-
<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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   set_reuse_addr	s   c    s   d Sd  S(   Ni   (    (   s   self(    (    s(   /usr/local/twc/lib/python2.2/asyncore.pys   readables   s   macc    s    !|  i Sd  S(   N(   s   selfs	   accepting(   s   self(    (    s(   /usr/local/twc/lib/python2.2/asyncore.pys   writable s   c    s   #$d Sd  S(   Ni   (    (   s   self(    (    s(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   handle_write_events   c    s   |  i   d  S(   N(   s   selfs   handle_expt(   s   self(    (    s(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   initiate_sends   	c    s   |  i   d  S(   N(   s   selfs   initiate_send(   s   self(    (    s(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   sends   (   s   Nones   __init__s   initiate_sends   handle_writes   writables   send(    (    (    s(   /usr/local/twc/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   is   [s   ] [c    s   d i  |   S(   Ns   |(   s   joins   x(   s   x(    (    s(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   sends   c    s   t  i |  i  Sd  S(   N(   s   oss   closes   selfs   fd(   s   self(    (    s(   /usr/local/twc/lib/python2.2/asyncore.pys   closes   c    s   |  i Sd  S(   N(   s   selfs   fd(   s   self(    (    s(   /usr/local/twc/lib/python2.2/asyncore.pys   filenos   (   s   __init__s   recvs   sends   reads   writes   closes   fileno(    (    (    s(   /usr/local/twc/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(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   set_file$s   (   s   __init__s   set_file(    (    (    s(   /usr/local/twc/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(   /usr/local/twc/lib/python2.2/asyncore.pys   ?/ s2   :	-"'