(conn)
Enter a splitbrain context in which imports take place over the given RPyC connection (expected to 
    be a SlaveService). You can enter this context only after calling ``enable()``
Enter a splitbrain context in which imports take place over the given RPyC connection (expected to 
    be a SlaveService). You can enter this context only after calling ``enable()``
Enter a splitbrain context in which imports take place over the given RPyC connection ( expected to be a SlaveService ) . You can enter this context only after calling enable ()
def splitbrain(conn):
    """Enter a splitbrain context in which imports take place over the given RPyC connection (expected to 
    be a SlaveService). You can enter this context only after calling ``enable()``"""
    if not _enabled:
        enable_splitbrain()
        #raise ValueError("Splitbrain not enabled")
    prev_conn = getattr(router, "conn", None)
    prev_modules = sys.modules.copy()
    router.conn = conn
    prev_stdin = conn.modules.sys.stdin
    prev_stdout = conn.modules.sys.stdout
    prev_stderr = conn.modules.sys.stderr
    conn.modules["sys"].stdin = sys.stdin
    conn.modules["sys"].stdout = sys.stdout
    conn.modules["sys"].stderr = sys.stderr
    try:
        yield
    finally:
        conn.modules["sys"].stdin = prev_stdin
        conn.modules["sys"].stdout = prev_stdout
        conn.modules["sys"].stderr = prev_stderr
        sys.modules.clear()
        sys.modules.update(prev_modules)
        router.conn = prev_conn
        if not router.conn:
            del router.conn
def splitbrain ( conn ) : if not _enabled : enable_splitbrain ( ) #raise ValueError("Splitbrain not enabled") prev_conn = getattr ( router , "conn" , None ) prev_modules = sys . modules . copy ( ) router . conn = conn prev_stdin = conn . modules . sys . stdin prev_stdout = conn . modules . sys . stdout prev_stderr = conn . modules . sys . stderr conn . modules [ "sys" ] . stdin = sys . stdin conn . modules [ "sys" ] . stdout = sys . stdout conn . modules [ "sys" ] . stderr = sys . stderr try : yield finally : conn . modules [ "sys" ] . stdin = prev_stdin conn . modules [ "sys" ] . stdout = prev_stdout conn . modules [ "sys" ] . stderr = prev_stderr sys . modules . clear ( ) sys . modules . update ( prev_modules ) router . conn = prev_conn if not router . conn : del router . conn