;ς
ν+ί?c           @   s  d  Z  d k l Z d k l Z d k l Z l Z l Z l	 Z	 l
 Z
 d k l Z l Z d k Td k l Z d k Z d k Z d k l Z l Z d	 Z h  Z h  Z e i d
 e i d h  d d < Z e i e  e i   Z d   Z  e  Z! d e i" f d     YZ# e e  Z$ d e f d     YZ% e$ i& d   e% i'  e$ i& d   e% i(  e$ i& d   e% i)  e$ i& d   e% i*  d S(   s4  TCP-ghost

Handles pass-through Presentations, Requests for symbols and
resolutions (associating names for things with connexions), Listens,
and Closes.

Could also answer requests for (host . port) pairs by establishing outbound
connexions and returning write-handles to requesters, or something like that.
(   s   clone(   s   puke(   s   Requests   Presentations   Paths   Listens   Close(   s   Ghosts   PredicateGhost(   s   *(   s   dispatchN(   s   AF_INETs   SOCK_STREAMs   tcps   targets   kwargss   timeouti   c      	      sP    i i  t   i t  o) t   d t t	   i i  d  Sn t t	   i       d   } t i   o t   |   nΌ t  d |  t    o[ y  i   Wn0 t i i j
 o } d   i | f GHqLXt   d  d  SnB y  i   Wn0 t i i j
 o } d   i | f GHn Xd  S(   Ns   actors   targetc              s?   t  i t d  d     t  i t  d  d    d  S(   Ns   actors   target(   s   dispatchs   schedules   Listens   actors   dests   clones   aff(    (   s   dests   actors   aff(    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys	   continue_%   s    s   callbacks    error making %s listen to %s: %ss   error connecting %s to %s: %s(   s   affs   targets   tails   dests
   isinstances   actors
   ReadWriters   clones   Paths   ghosts	   continue_s
   connexionss   has_keys	   is_listens   listens   asyncores   sockets   errors   es   connect(   s   affs   es	   continue_s   dests   actor(    (   s   affs   dests   actors8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   pass_   s(    
s	   Connexionc           B   sb   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   Nc         O   s¬   t  |  _ | i d  o | d |  _ | d =n | |  _ t i i	 |  | |  |  i o |  i t t  n t i   t i   o t  t _ t i   n t i   d  S(   Ns   callback(   s   Falses   selfs   tryings   kwargss   has_keys   handle_connects   ghosts   asyncores   dispatcher_with_sends   __init__s   argss   sockets   create_sockets   AF_INETs   SOCK_STREAMs   selector_mutexs   acquires   selectors   isAlives   _Thread__starteds   starts   release(   s   selfs   ghosts   argss   kwargs(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   __init__>   s    		
	c         C   s,   |  i p |  i p |  i o
 |  i i Sd  S(   N(   s   selfs   tryings	   acceptings	   connecteds   ghosts   parsers(   s   self(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   readableL   s    c         C   s   |  i o t i i |   Sd  S(   N(   s   selfs   tryings   asyncores   dispatcher_with_sends   writable(   s   self(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   writableO   s    c         C   s4   |  i d  } | o |  i i t d | n d  S(   Ni   s   object(   s   selfs   recvs   ss   ghosts	   broadcasts   Presentation(   s   selfs   s(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   handle_readQ   s    c         C   s   t  i i |   } | Sd  S(   N(   s   asyncores   dispatcher_with_sends   handle_writes   selfs   res(   s   selfs   res(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   handle_writeU   s    c         G   s   t  i i |  |  } | Sd  S(   N(   s   asyncores   dispatcher_with_sends   sends   selfs   argss   res(   s   selfs   argss   res(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   sendX   s    c         C   s2   |  i   \ } } |  i i | d | t | <d  S(   Ns   socket(   s   selfs   accepts   socks   infos   ghosts   spawns
   connexions(   s   selfs   infos   sock(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   handle_accept[   s    c         C   s   |  i   d  S(   N(   s   selfs   close(   s   self(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   handle_close^   s    c         G   s&   t  i i |  |  } t |  _ | Sd  S(   N(   s   asyncores   dispatcher_with_sends   connects   selfs   argss   ress   Trues   trying(   s   selfs   argss   res(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   connect`   s    	c         C   s<   |  i o t |  i i =n t |  i i =t i i |   d  S(   N(	   s   selfs	   acceptings	   listenerss   ghosts   targets
   connexionss   asyncores   dispatcher_with_sends   close(   s   self(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   closed   s    
(   s   __name__s
   __module__s   __init__s   readables   writables   handle_reads   handle_writes   sends   handle_accepts   handle_closes   connects   close(    (    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys	   Connexion=   s   									s
   ReadWriterc           B   sz   t  Z d Z d   Z 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         C   s   t  |  |  Sd  S(   N(   s   connexion_reactors   selfs   aff(   s   selfs   aff(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys	   weltgeistq   s    c         O   s   | i d  } | o | |  _ n t i |  |  i  h  |  _ | |  _ t |  |  _	 t
 |  d | i d  d | i d  |  _ d  S(   Ns	   weltgeists   socks   sockets   callback(   s   kwargss   gets	   weltgeists   selfs   Ghosts   __init__s
   vocabularys   targets   lists   parserss	   Connexions	   connexion(   s   selfs   targets   parserss   kwargss	   weltgeist(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   __init__r   s    		c         C   s*   |  i i |  i  } |  t |  i <| Sd  S(   N(   s   selfs	   connexions   connects   targets   ress
   connexions(   s   selfs   res(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   connect|   s    c         C   s7   |  i i |  i  |  i i |  i  |  t |  i <d  S(   N(   s   selfs	   connexions   binds   targets   listens   backlogs	   listeners(   s   self(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   listen   s    c         O   s!   |  i | t |  i  |   Sd  S(   N(   s   selfs	   __class__s   argss   tuples   parserss   kwargs(   s   selfs   argss   kwargs(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   spawn   s    c         C   s/   d t  t |   d } | |  i | <| Sd  S(   Ns   corpus-i   (   s   hexs   ids   corpuss   symbols   selfs
   vocabulary(   s   selfs   corpuss   symbol(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys
   symbol_for   s    c         C   sY   | i } t | t  o |  i | } n |  i |  } t d |  d | d | i  Sd  S(   Ns   actors   objects   target(	   s   reqs   items
   isinstances   strs   selfs
   vocabularys
   symbol_fors   Presentations   actor(   s   selfs   reqs   item(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   resolve   s
    	c         C   s   |  i i   d  S(   N(   s   selfs	   connexions   close(   s   selfs   close(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys
   disconnect   s    c         C   s1   | i } | |  i j o |  i i |  n d  S(   N(   s   listens   actors   listeners   selfs   parserss   append(   s   selfs   listens   listener(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys	   subscribe   s    	c         C   sL   | i } y |  i i |  Wn( t i i j
 o } |  Gd G| GHn Xd  S(   Ns   failed to send:(
   s   presents   objects   ss   selfs	   connexions   sends   asyncores   sockets   errors   e(   s   selfs   presents   es   s(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   write   s
    	c         C   s   |  i i |  d  S(   N(   s   selfs   parserss   appends   d(   s   selfs   d(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   delegate    s    c         K   s=   x6 |  i D]+ } | d |  d | |  } t i |  q
 Wd  S(   Ns   actors   target(   s   selfs   parserss   parsers   class_s   argss   affs   dispatchs   schedule(   s   selfs   class_s   argss   parsers   aff(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys	   broadcast’   s    
 (   s   __name__s
   __module__s   backlogs	   weltgeists   __init__s   connects   listens   spawns
   symbol_fors   resolves
   disconnects	   subscribes   writes   delegates	   broadcast(    (    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys
   ReadWritern   s   		
									c         G   s
   t  |   S(   N(   s
   is_requests   c(   s   ss   c(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   <lambda>§   s    c         G   s
   t  |   S(   N(   s   is_presentations   c(   s   ss   c(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   <lambda>¨   s    c         G   s
   t  |   S(   N(   s	   is_listens   c(   s   ss   c(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   <lambda>©   s    c         G   s
   t  |   S(   N(   s   is_closes   c(   s   ss   c(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   <lambda>ͺ   s    (+   s   __doc__s   dp2.utils   clones   dp2.ghostutils   pukes   dp2.corporas   Requests   Presentations   Paths   Listens   Closes
   dp2.ghostss   Ghosts   PredicateGhosts   dp2.predicatess   dp2s   dispatchs   asyncores	   threadings   sockets   AF_INETs   SOCK_STREAMs   names
   connexionss	   listenerss   Threads   loops   selectors	   setDaemons   Trues   Locks   selector_mutexs   pass_s   ghosts   dispatcher_with_sends	   Connexions   connexion_reactors
   ReadWriters   delegates   resolves   writes	   subscribes
   disconnect(   s   asyncores
   connexionss   SOCK_STREAMs   dispatchs
   ReadWriters   Presentations   Listens   pass_s   selector_mutexs   pukes   connexion_reactors   Paths   Ghosts   clones   Requests   selectors   ghosts   names   PredicateGhosts   AF_INETs	   threadings	   listenerss   Closes	   Connexion(    (    s8   /usr/home/rozzin/html/pedagogy/race-condition/dp2/tcp.pys   ?   s0   %		$	/9