;ò
ÎÑAHc           @   s4  d  k  Z  d k l Z l Z d k l Z d k l Z d k l	 Z	 d  k
 Z
 d  k Z d  k Z d  k Z d k l Z l Z d k l Z l Z l Z l Z l Z d  k Z d „  Z d „  Z d	 e f d
 „  ƒ  YZ d f  d „  ƒ  YZ e Z e d j o: e d g  d h  d d <d d <ƒ Z e i ƒ  d GHn d  S(   N(   s   reactors   threads(   s   make_IPython(   s   InteractiveShell(   s   Struct(   s   signals   SIGINT(   s   Terms   warns   errors
   flag_callss
   ask_yes_noc          C   s   d k  l }  |  i ƒ  d S(   s.    Install gtk2 reactor, needs to be called bef (   s   gtk2reactorN(   s   twisted.internets   gtk2reactors   install(   s   gtk2reactor(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   install_gtk2   s     c             sC   d k  l } | i ‰  d t f ‡  d †  ƒ  Y} | ƒ  | _ ˆ  Sd S(   s  Modifies Twisted's reactor with a dummy so user code does
    not block IPython.  This function returns the original
    'twisted.internet.reactor' that has been hijacked.

    NOTE: Make sure you call this *AFTER* you've installed
    the reactor of your choice.
    (   s   internets   DummyReactorc              s)   t  Z d „  Z ‡  d †  Z ‡  d †  Z RS(   Nc         C   s   d  S(   N(    (   s   self(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   run   s    c            s   t  ˆ  | ƒ Sd  S(   N(   s   getattrs   orig_reactors   name(   s   selfs   name(   s   orig_reactor(    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   __getattr__!   s    c            s   t  ˆ  | | ƒ Sd  S(   N(   s   setattrs   orig_reactors   names   value(   s   selfs   names   value(   s   orig_reactor(    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   __setattr__#   s    (   s   __name__s
   __module__s   runs   __getattr__s   __setattr__(    (   s   orig_reactor(    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   DummyReactor   s   	N(   s   twisteds   internets   reactors   orig_reactors   objects   DummyReactor(   s   orig_reactors   DummyReactors   internet(    (   s   orig_reactors@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   hijack_reactor   s     	s   TwistedInteractiveShellc           B   s\   t  Z d  Z e Z e e d e d e ƒ e e d d „ Z d d d „ Z d „  Z	 d	 „  Z
 RS(
   s   Simple multi-threaded shell.s   optss   argss    c   
      K   s   t  i |  | | | | | | ƒ t	 i	 ƒ  |  _
 t |  _ | i d g  ƒ }	 x) |	 D]! } t | ƒ o t d ‚ qP qP W|	 |  _ t |  _ t |  _ t |  _ d S(   sB   Similar to the normal InteractiveShell, but with threading controls   on_kills#   on_kill must be a list of callablesN(   s   InteractiveShells   __init__s   selfs   names   usages   rcs   user_nss   user_global_nss   banner2s   Queues
   code_queues   Nones   _kills   kws   gets   on_kills   ts   callables	   TypeErrors   worker_idents   Falses   reactor_starteds   Trues	   first_run(
   s   selfs   names   usages   rcs   user_nss   user_global_nss   banner2s   kws   ts   on_kill(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   __init__5   s     
	 			s   <input>s   singlec         C   s†  t  i o t t  _ t Sn |  i o t Sn y |  i | | | ƒ } Wn- t t t f j
 o |  i | ƒ t Sn X| t j o t Sn |  i p> |  i t j o |  i p# |  i t i ƒ  j p t  i | ƒ o t i |  | ƒ d Sn t |  _ t i ƒ  t i ƒ  f \ } } |  i i | | | f ƒ t i d |  i ƒ | i  d ƒ | i! ƒ  o d GHd GHt |  _ n | i  ƒ  t Sd S(   s´   Compile and run some source in the interpreter.

        Modified version of code.py's runsource(), to handle threading issues.
        See the original for full docstring details.Nf0.0i   s-   Warning: Timeout for mainloop thread exceededs=   switching to nonthreaded mode (until mainloop wakes up again)("   s   shellglobalss   KBINTs   Falses   selfs   _kills   Trues   compiles   sources   filenames   symbols   codes   OverflowErrors   SyntaxErrors
   ValueErrors   showsyntaxerrors   Nones   reactor_starteds   worker_idents	   first_runs   threads	   get_idents   run_in_frontends   InteractiveShells   runcodes	   threadings   Events   completed_evs   received_evs
   code_queues   puts   reactors	   callLaters   waits   isSet(   s   selfs   sources   filenames   symbols   codes   received_evs   completed_ev(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys	   runsourceM   s6     
	
	L	
c         C   ss  t  i ƒ  |  _ |  i oW t i d It i i ƒ  x |  i D] } | ƒ  q= Wt i d IJ|  i i
 ƒ  t Sn y t t t i ƒ Wn t j
 o n Xt } xÈ n oÀ y |  i i ƒ  \ } } } Wn t i j
 o Pn X| i
 ƒ  ze y t t _ t i |  | ƒ WnA t j
 o5 d GHx% |  i i ƒ  o |  i i ƒ  } q#WPn XWd t t _ | i
 ƒ  Xqª Wt Sd S(   sQ   Execute a code object.

        Multithreaded wrapper around IPython's runcode().s   Closing threads...s   Done.i   s    Keyboard interrupted in mainloopN(    s   threads	   get_idents   selfs   worker_idents   _kills   Terms   couts   flushs   on_kills   tokills   sets   Trues   signals   SIGINTs   shellglobalss   sigint_handlers   SystemErrors   Nones   code_to_runs
   code_queues
   get_nowaits   completed_evs   received_evs   Queues   Emptys   CODE_RUNs   InteractiveShells   runcodes   KeyboardInterrupts   emptys   codes   False(   s   selfs   code_to_runs   codes   received_evs   completed_evs   tokill(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   runcode„   sL     

   
		 
 	c         C   s3   t  i ƒ  |  _ t i d |  i ƒ |  i i ƒ  d S(   s6   Kill the thread, returning when it has been shut down.f0.0N(   s	   threadings   Events   selfs   _kills   reactors	   callLaters   runcodes   wait(   s   self(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   killÃ   s     (   s   __name__s
   __module__s   __doc__s   Trues
   isthreadeds   Nones   Structs   __init__s	   runsources   runcodes   kill(    (    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   TwistedInteractiveShell)   s    	'7	?s   IPShellTwistedc           B   s;   t  Z d  Z d Z e e d e d „ Z d „  Z d „  Z RS(   sí   Run a Twisted reactor while in an IPython session.

    Python commands can be passed to the thread where they will be
    executed.  This is implemented by periodically checking for
    passed code using a Twisted reactor callback.
    f0.01i   c   
         s˜   d k  l } t ƒ  ˆ  _ ˆ  i i } d „  } | ˆ  i _ ˆ  i i ‰ t	 ˆ  _
 ‡ ‡  d †  }	 |	 ˆ  i _ t | d | d | d | d | g ƒˆ  _ d  S(   N(   s   reactorc           C   s   d  S(   N(    (    (    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   reactorstopÞ   s    c              s%   x t  o ˆ i o ˆ  ƒ  q Wd  S(   N(   s   Trues   selfs   quittings   reactorrun_orig(    (   s   reactorrun_origs   self(    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys
   reactorrunã   s     s   user_nss   debugs   shell_classs   on_kill(   s   twisted.internets   reactors   hijack_reactors   selfs   stops   mainquits   reactorstops   runs   reactorrun_origs   Falses   quittings
   reactorruns   make_IPythons   argvs   user_nss   debugs   shell_classs   IP(
   s   selfs   argvs   user_nss   debugs   shell_classs   reactors   reactorstops   mainquits   reactorrun_origs
   reactorrun(    (   s   selfs   reactorrun_origs@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   __init__Õ   s    		c         C   s'   |  i i ƒ  t |  _ |  i i ƒ  d  S(   N(   s   selfs   IPs   mainloops   Trues   quittings   kill(   s   self(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   runî   s    	c            sG   d „  ‰ ‡  ‡ d †  } t i | ƒ t ˆ  i _ ˆ  i i ƒ  d GHd  S(   Nc         C   s   d Gt  |  ƒ GHd  S(   Ns   mainLoopThreadDeath: (   s   strs   r(   s   r(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   mainLoopThreadDeathô   s    c             s#   t  i ˆ  i ƒ }  |  i ˆ ƒ d  S(   N(   s   threadss   deferToThreads   selfs   runs   ds   addBoths   mainLoopThreadDeath(   s   d(   s   selfs   mainLoopThreadDeath(    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   spawnMainloopThreadö   s    s   mainloop ending....(	   s   mainLoopThreadDeaths   spawnMainloopThreads   reactors   callWhenRunnings   Trues   selfs   IPs   reactor_starteds   run(   s   selfs   mainLoopThreadDeaths   spawnMainloopThread(    (   s   selfs   mainLoopThreadDeaths@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   mainloopó   s    	(	   s   __name__s
   __module__s   __doc__s   TIMEOUTs   Nones   TwistedInteractiveShells   __init__s   runs   mainloop(    (    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   IPShellTwistedË   s
    	s   __main__s   argvs   user_nss   __name__s   __example__s   hellos   worlds   Goodbye!(   s   syss   twisted.internets   reactors   threadss   IPython.ipmakers   make_IPythons   IPython.iplibs   InteractiveShells   IPython.ipstructs   Structs   Queues   threads	   threadings   signals   SIGINTs   IPython.genutilss   Terms   warns   errors
   flag_callss
   ask_yes_nos   shellglobalss   install_gtk2s   hijack_reactors   TwistedInteractiveShells   IPShellTwisteds   Trues   existss   __name__s   shells   mainloop(   s   reactors   existss
   flag_callss   syss   IPShellTwisteds   Structs   signals   SIGINTs   Terms   shells   make_IPythons   hijack_reactors   shellglobalss   threadss
   ask_yes_nos   TwistedInteractiveShells   Queues   threads   InteractiveShells   warns	   threadings   errors   install_gtk2(    (    s@   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/twshell.pys   ?   s$   	$%			¢3		
