예제 #1
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_result_unpickling(self):
        with make_connection() as conn:

            def on_unpickle():
                self.assertIs(across.get_connection(), conn)

            with self.assertRaises(ValueError):
                across.get_connection()
            conn.call(Box(lambda: PickleObserver(on_unpickle=on_unpickle)))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #2
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_call_pickling(self):
        with make_connection() as conn:

            def on_pickle():
                self.assertIs(across.get_connection(), conn)

            with self.assertRaises(ValueError):
                across.get_connection()
            conn.call(nop, PickleObserver(on_pickle=on_pickle))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #3
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_call_unpickling(self):
        with make_connection() as conn:

            def on_unpickle():
                remote_conn = across.get_connection()
                self.assertIsInstance(remote_conn, across.Connection)
                self.assertIsNot(remote_conn, conn)

            with self.assertRaises(ValueError):
                across.get_connection()
            conn.call(nop, PickleObserver(on_unpickle=on_unpickle))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #4
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_invocation(self):
        with make_connection() as conn:

            def invoke():
                remote_conn = across.get_connection()
                self.assertIsInstance(remote_conn, across.Connection)
                self.assertIsNot(remote_conn, conn)

            with self.assertRaises(ValueError):
                across.get_connection()
            conn.call(Box(invoke))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #5
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_error_unpickling(self):
        with make_connection() as conn:

            def on_unpickle():
                self.assertIs(across.get_connection(), conn)

            def func():
                raise ArithmeticError(PickleObserver(on_unpickle=on_unpickle))

            with self.assertRaises(ValueError):
                across.get_connection()
            with self.assertRaises(ArithmeticError):
                conn.call(Box(func))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #6
0
파일: getconn.py 프로젝트: rusek/across
    def test_get_connection_during_result_pickling(self):
        remote_conn = Box()

        def on_pickle():
            self.assertIs(across.get_connection(), remote_conn.value)

        def func():
            remote_conn.value = across.get_connection()
            return PickleObserver(on_pickle=on_pickle)

        with make_connection() as conn:
            with self.assertRaises(ValueError):
                across.get_connection()
            conn.call(Box(func))
            with self.assertRaises(ValueError):
                across.get_connection()
예제 #7
0
파일: logging.py 프로젝트: rusek/across
def _setup_remote_logging():
    _remote_conn.value = across.get_connection()
    handler = AcrossHandler()
    handler.addFilter(_RemoteSideFilter())
    handler.setLevel(logging.INFO)
    _logger.addHandler(handler)
    _remote_handler.value = handler
예제 #8
0
파일: getconn.py 프로젝트: rusek/across
 def func():
     remote_conn.value = across.get_connection()
     raise ArithmeticError(PickleObserver(on_pickle=on_pickle))
예제 #9
0
파일: getconn.py 프로젝트: rusek/across
 def on_pickle():
     self.assertIs(across.get_connection(), remote_conn.value)
예제 #10
0
파일: getconn.py 프로젝트: rusek/across
 def on_unpickle():
     self.assertIs(across.get_connection(), conn)
예제 #11
0
파일: getconn.py 프로젝트: rusek/across
 def func():
     remote_conn.value = across.get_connection()
     return PickleObserver(on_pickle=on_pickle)
예제 #12
0
파일: getconn.py 프로젝트: rusek/across
 def invoke_nested():
     self.assertIs(across.get_connection(), conn)
예제 #13
0
파일: getconn.py 프로젝트: rusek/across
 def invoke():
     remote_conn = across.get_connection()
     self.assertIsInstance(remote_conn, across.Connection)
     self.assertIsNot(remote_conn, conn)
     remote_conn.call(Box(invoke_nested))
     self.assertIs(across.get_connection(), remote_conn)
예제 #14
0
파일: getconn.py 프로젝트: rusek/across
 def invoke():
     remote_conn = across.get_connection()
     self.assertIsInstance(remote_conn, across.Connection)
     self.assertIsNot(remote_conn, conn)
예제 #15
0
파일: logging.py 프로젝트: rusek/across
 def filter(self, record):
     try:
         conn = across.get_connection()
     except ValueError:
         conn = None
     return (conn == _remote_conn.value) != self._negate
예제 #16
0
파일: getconn.py 프로젝트: rusek/across
 def on_unpickle():
     remote_conn = across.get_connection()
     self.assertIsInstance(remote_conn, across.Connection)
     self.assertIsNot(remote_conn, conn)
예제 #17
0
파일: call.py 프로젝트: rusek/across
 def factorial(n):
     return 1 if n == 0 else n * across.get_connection().call(
         factorial, n - 1)