Ejemplo n.º 1
0
def test_using_threads():
    capnp.remove_event_loop(True)
    capnp.create_event_loop(True)

    read, write = socket.socketpair(socket.AF_UNIX)

    def run_server():
        restorer = SimpleRestorer()
        server = capnp.TwoPartyServer(write, restorer)
        capnp.wait_forever()

    server_thread = threading.Thread(target=run_server)
    server_thread.daemon = True
    server_thread.start()

    client = capnp.TwoPartyClient(read)

    ref = test_capability_capnp.TestSturdyRefObjectId.new_message(tag='testInterface')
    cap = client.restore(ref)
    cap = cap.cast_as(test_capability_capnp.TestInterface)

    remote = cap.foo(i=5)
    response = remote.wait()

    assert response.x == '125'
Ejemplo n.º 2
0
def test_using_threads():
    capnp.remove_event_loop(True)
    capnp.create_event_loop(True)

    read, write = socket.socketpair(socket.AF_UNIX)

    def run_server():
        restorer = SimpleRestorer()
        server = capnp.TwoPartyServer(write, restorer)
        capnp.wait_forever()

    server_thread = threading.Thread(target=run_server)
    server_thread.daemon = True
    server_thread.start()

    client = capnp.TwoPartyClient(read)

    ref = test_capability_capnp.TestSturdyRefObjectId.new_message(
        tag='testInterface')
    cap = client.restore(ref)
    cap = cap.cast_as(test_capability_capnp.TestInterface)

    remote = cap.foo(i=5)
    response = remote.wait()

    assert response.x == '125'
Ejemplo n.º 3
0
def test_making_threaded_event_loop():
    '''
    Threaded event loop test
    '''
    capnp.remove_event_loop(True)
    capnp.create_event_loop(True)

    capnp.remove_event_loop()
    capnp.create_event_loop(True)
Ejemplo n.º 4
0
def test_making_event_loop():
    '''
    Event loop test
    '''
    capnp.remove_event_loop(True)
    capnp.create_event_loop()

    capnp.remove_event_loop()
    capnp.create_event_loop()
Ejemplo n.º 5
0
def test_making_event_loop():
    """
    Event loop test
    """
    capnp.remove_event_loop(True)
    capnp.create_event_loop()

    capnp.remove_event_loop()
    capnp.create_event_loop()
Ejemplo n.º 6
0
def test_making_threaded_event_loop():
    """
    Threaded event loop test
    """
    # The following raises a KjException, and if not caught causes an SIGABRT:
    # kj/async.c++:973: failed: expected head == nullptr; EventLoop destroyed with events still in the queue.
    # Memory leak?; head->trace() = kj::_::ForkHub<kj::_::Void>
    # kj::_::AdapterPromiseNode<kj::_::Void, kj::_::PromiseAndFulfillerAdapter<void> >
    # stack: ...
    # python(..) malloc: *** error for object 0x...: pointer being freed was not allocated
    # python(..) malloc: *** set a breakpoint in malloc_error_break to debug
    # Fatal Python error: Aborted
    capnp.remove_event_loop(KjException)
    capnp.create_event_loop(KjException)

    capnp.remove_event_loop()
    capnp.create_event_loop(KjException)
Ejemplo n.º 7
0
def test_using_threads():
    '''
    Thread test
    '''
    capnp.remove_event_loop(True)
    capnp.create_event_loop(True)

    read, write = socket.socketpair()

    def run_server():
        _ = capnp.TwoPartyServer(write, bootstrap=Server())
        capnp.wait_forever()

    server_thread = threading.Thread(target=run_server)
    server_thread.daemon = True
    server_thread.start()

    client = capnp.TwoPartyClient(read)
    cap = client.bootstrap().cast_as(test_capability_capnp.TestInterface)

    remote = cap.foo(i=5)
    response = remote.wait()

    assert response.x == '125'
Ejemplo n.º 8
0
#!/usr/bin/env python

from __future__ import print_function

import argparse
import threading
import time
import capnp

import thread_capnp

capnp.remove_event_loop()
capnp.create_event_loop(threaded=True)


def parse_args():
    parser = argparse.ArgumentParser(
        usage='Connects to the Example thread server \
at the given address and does some RPCs')
    parser.add_argument("host", help="HOST:PORT")

    return parser.parse_args()


class StatusSubscriber(thread_capnp.Example.StatusSubscriber.Server):
    '''An implementation of the StatusSubscriber interface'''
    def status(self, value, **kwargs):
        print('status: {}'.format(time.time()))


def start_status_thread(host):
Ejemplo n.º 9
0
#!/usr/bin/env python

from __future__ import print_function

import argparse
import threading
import time
import capnp

import thread_capnp

capnp.remove_event_loop()
capnp.create_event_loop(threaded=True)


def parse_args():
  parser = argparse.ArgumentParser(usage='Connects to the Example thread server \
at the given address and does some RPCs')
  parser.add_argument("host", help="HOST:PORT")

  return parser.parse_args()


class StatusSubscriber(thread_capnp.Example.StatusSubscriber.Server):

    '''An implementation of the StatusSubscriber interface'''

    def status(self, value, **kwargs):
        print('status: {}'.format(time.time()))

Ejemplo n.º 10
0
def test_making_event_loop():
    capnp.remove_event_loop(True)
    capnp.create_event_loop()

    capnp.remove_event_loop()
    capnp.create_event_loop()
Ejemplo n.º 11
0
 def stop():
     capnp.remove_event_loop(ignore_errors=True)
     exit(0)
Ejemplo n.º 12
0
def test_making_threaded_event_loop():
    capnp.remove_event_loop(True)
    capnp.create_event_loop(True)

    capnp.remove_event_loop()
    capnp.create_event_loop(True)