-
<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 r 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 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   ? t  Z @ RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/asyncore.pys   ExitNow? s   	i    f0.0c    sx  D E | t j o F t } n G | oJ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 | | | |   \ } } } WnN P t i j
 o< } Q | d t j o
 R   n S g  } g  } g  } n XU t o V | G| G| GHn X x | DX ] } Y y Z | | } Wn [ t j
 o \ qNn X^ y _ | i   Wn5 ` t j
 o a t  n b c | i   n XqNWe x | De ] } f y g | | } Wn h t j
 o i qn Xk y l | i   Wn5 m t j
 o n t  n o p | 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/lib/python2.2/asyncore.pys   pollD sT   
 (


 	
 	c    s  r s d  k  } t | t j o u t } n v |  t j	 o x t |  d  }  n y | oz g  } { x | i   D{ ]} \ } } | 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/lib/python2.2/asyncore.pys   poll2r 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/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/lib/python2.2/asyncore.pys   loop s   
	 
s
   dispatcherc      s   t  Z  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 1d   Z 5d   Z Ad   Z Kd   Z Vd   Z hd   Z nd   Z ud   Z x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/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/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/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/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/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/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/lib/python2.2/asyncore.pys   set_reuse_addr
s   c    s   d Sd  S(   Ni   (    (   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   readables   s   macc    s   !"|  i Sd  S(   N(   s   selfs	   accepting(   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   writable!s   c    s   $%d Sd  S(   Ni   (    (   s   self(    (    s   /usr/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/lib/python2.2/asyncore.pys   listen+s    c    s&   12| |  _  3|  i i |  Sd  S(   N(   s   addrs   selfs   sockets   bind(   s   selfs   addr(    (    s   /usr/lib/python2.2/asyncore.pys   bind1s   c    s   56d |  _ 7|  i i |  } 8| t t t f j o 9d  Sn :| 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/lib/python2.2/asyncore.pys   connect5s   c    s{   ABy) C|  i i   \ } } D| | f SWnE Et i j
 o3 } F| d t j o Gn It i |  n Xd  S(   Ni    (   s   selfs   sockets   accepts   conns   addrs   errors   whys   EWOULDBLOCK(   s   selfs   whys   conns   addr(    (    s   /usr/lib/python2.2/asyncore.pys   acceptAs   c    s}   KLy  M|  i i |  } N| SWnP Ot i j
 o> } P| d t j o Qd Sn St i |  Td Sn Xd  S(   Ni    (   s   selfs   sockets   sends   datas   results   errors   whys   EWOULDBLOCK(   s   selfs   datas   whys   result(    (    s   /usr/lib/python2.2/asyncore.pys   sendKs   c    s   VWyC X|  i i |  } Y| o \|  i   ]d Sn _| SWn_ `t i j
 oM } b| d t t	 t
 g j o c|  i   dd Sn f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/lib/python2.2/asyncore.pys   recvVs   c    s$   hi|  i   j|  i i   d  S(   N(   s   selfs   del_channels   sockets   close(   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   closehs   c    s   not  |  i |  Sd  S(   N(   s   getattrs   selfs   sockets   attr(   s   selfs   attr(    (    s   /usr/lib/python2.2/asyncore.pys   __getattr__ns   c    s$   uvt  i i d t |   d  S(   Ns   log: %s
(   s   syss   stderrs   writes   strs   message(   s   selfs   message(    (    s   /usr/lib/python2.2/asyncore.pys   logus   s   infoc    s4   xyt  p
 | d j o zd | | f GHn d  S(   Ns   infos   %s: %s(   s	   __debug__s   types   message(   s   selfs   messages   type(    (    s   /usr/lib/python2.2/asyncore.pys   log_infox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/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/lib/python2.2/asyncore.pys   handle_write_events   c    s   |  i   d  S(   N(   s   selfs   handle_expt(   s   self(    (    s   /usr/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/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/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/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/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/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/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/lib/python2.2/asyncore.pys   handle_closes   ('   s   __name__s
   __module__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/lib/python2.2/asyncore.pys
   dispatcher sH   						
s   dispatcher_with_sendc      sJ   t  Z 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/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/lib/python2.2/asyncore.pys   initiate_sends   	c    s   |  i   d  S(   N(   s   selfs   initiate_send(   s   self(    (    s   /usr/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/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/lib/python2.2/asyncore.pys   sends   (   s   __name__s
   __module__s   Nones   __init__s   initiate_sends   handle_writes   writables   send(    (    (    s   /usr/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/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/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/lib/python2.2/asyncore.pys	   close_alls    	s   posixs   file_wrapperc      sY   t  Z 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/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/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/lib/python2.2/asyncore.pys   sends   c    s   t  i |  i  Sd  S(   N(   s   oss   closes   selfs   fd(   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   closes   c    s   |  i Sd  S(   N(   s   selfs   fd(   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   filenos   (	   s   __name__s
   __module__s   __init__s   recvs   sends   reads   writes   closes   fileno(    (    (    s   /usr/lib/python2.2/asyncore.pys   file_wrappers   			s   file_dispatcherc      s#   t  Z 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/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/lib/python2.2/asyncore.pys   set_file$s   (   s   __name__s
   __module__s   __init__s   set_file(    (    (    s   /usr/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/lib/python2.2/asyncore.pys   ?/ s0   :	."'