-í
æ¶<c       st  d  Z  d k Z d k Z d k Z d k Z d k Z 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 Xd e i f d „  ƒ  YZ d Z d e 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 e i d j o6 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    s÷  | t j o
 t } n | oÕg  } g  } g  } xV | i ƒ  D]H \ } } | i	 ƒ  o | i
 | ƒ n | i ƒ  o | i
 | ƒ n q= Wy% t i | | | |  ƒ \ } } } WnB t i j
 o3 } | d t j o ‚  n g  } g  } g  } n Xt o | G| G| GHn xo | D]g } y | | } Wn t j
 o
 qn Xy | i ƒ  Wn) t j
 o t ‚ n | i ƒ  n XqWxo | D]g } y | | } Wn t j
 o
 q„n Xy | i ƒ  Wn) t j
 o t ‚ n | 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‡  d  k  } | t j o
 t } n |  t j	 o t |  d ƒ }  n | o;g  } xv | i ƒ  D]h \ } } d } | i ƒ  o | i } n | i ƒ  o | | i B} n | o | i | | f ƒ n q[ W| i  | |  ƒ } x£ | D]› \ } } y | | } Wn t j
 o
 qà n Xy< | | i @o | i ƒ  n | | i @o | i ƒ  n Wn) 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 ƒ  } | olxs | i ƒ  D]e \ } } d } | i ƒ  o t i } n | i ƒ  o | t i B} n | o | i | | ƒ n qX Wy | i |  ƒ } Wn6 t i j
 o' } | d t j o ‚  n g  } n Xx£ | D]› \ } } y | | } Wn t j
 o
 qn Xy< | t i @o | i ƒ  n | t i @o | i ƒ  n Wn) t j
 o t ‚ n | i ƒ  n Xq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    sh   | t j o
 t } n | o$ t t d ƒ o
 t } n t } n t	 } x | o | |  | ƒ qK 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      sZ  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 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    sm   | oY |  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	 oH 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    s(   | 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    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   fd(    (    s   /usr/lib/python2.2/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   type(    (    s   /usr/lib/python2.2/asyncore.pys   create_socketý s
    c    s)   | |  _ | 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    sV   y9 |  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    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   num(    (    s   /usr/lib/python2.2/asyncore.pys   listen+s    	
c    s   | |  _  |  i i | ƒ Sd  S(   N(   s   addrs   selfs   sockets   bind(   s   selfs   addr(    (    s   /usr/lib/python2.2/asyncore.pys   bind1s    	c    s|   d |  _ |  i i | ƒ } | t t t f j o 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    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   whys   conns   addr(    (    s   /usr/lib/python2.2/asyncore.pys   acceptA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   whys   result(    (    s   /usr/lib/python2.2/asyncore.pys   sendK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   why(    (    s   /usr/lib/python2.2/asyncore.pys   recvVs    

c    s   |  i ƒ  |  i i ƒ  d  S(   N(   s   selfs   del_channels   sockets   close(   s   self(    (    s   /usr/lib/python2.2/asyncore.pys   closehs    
c    s   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   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    s+   t  p
 | d j o 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    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   self(    (    s   /usr/lib/python2.2/asyncore.pys   handle_read_event|s    

	c    s0   |  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    sm   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      s8   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    s3   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    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   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  }  xS d oK |  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   /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     1	
#c    sI   |  t j o
 t }  n x! |  i ƒ  D] } | i i ƒ  q$ 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      sA   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    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   F_GETFLs   flagss   oss
   O_NONBLOCKs   F_SETFLs   set_file(   s   selfs   fds   flags(    (    s   /usr/lib/python2.2/asyncore.pys   __init__s    	c    s&   | |  _ 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   					7."'õ		