예제 #1
0
    def test_hub_exceptions(self):
        debug.hub_exceptions(True)
        server = eventlet.listen(('0.0.0.0', 0))
        client = eventlet.connect(('127.0.0.1', server.getsockname()[1]))
        client_2, addr = server.accept()

        def hurl(s):
            s.recv(1)
            {}[1]  # keyerror

        fake = six.StringIO()
        orig = sys.stderr
        sys.stderr = fake
        try:
            gt = eventlet.spawn(hurl, client_2)
            eventlet.sleep(0)
            client.send(b' ')
            eventlet.sleep(0)
            # allow the "hurl" greenlet to trigger the KeyError
            # not sure why the extra context switch is needed
            eventlet.sleep(0)
        finally:
            sys.stderr = orig
            self.assertRaises(KeyError, gt.wait)
            debug.hub_exceptions(False)
        # look for the KeyError exception in the traceback
        assert 'KeyError: 1' in fake.getvalue(), "Traceback not in:\n" + fake.getvalue()
예제 #2
0
    def test_hub_exceptions(self):
        debug.hub_exceptions(True)
        server = eventlet.listen(('0.0.0.0', 0))
        client = eventlet.connect(('127.0.0.1', server.getsockname()[1]))
        client_2, addr = server.accept()

        def hurl(s):
            s.recv(1)
            {}[1]  # keyerror

        fake = six.StringIO()
        orig = sys.stderr
        sys.stderr = fake
        try:
            gt = eventlet.spawn(hurl, client_2)
            eventlet.sleep(0)
            client.send(b' ')
            eventlet.sleep(0)
            # allow the "hurl" greenlet to trigger the KeyError
            # not sure why the extra context switch is needed
            eventlet.sleep(0)
        finally:
            sys.stderr = orig
            self.assertRaises(KeyError, gt.wait)
            debug.hub_exceptions(False)
        # look for the KeyError exception in the traceback
        self.assert_('KeyError: 1' in fake.getvalue(),
                     "Traceback not in:\n" + fake.getvalue())
예제 #3
0
파일: __init__.py 프로젝트: clayg/swift
def quiet_eventlet_exceptions():
    orig_state = greenpool.DEBUG
    eventlet_debug.hub_exceptions(False)
    try:
        yield
    finally:
        eventlet_debug.hub_exceptions(orig_state)
예제 #4
0
def quiet_eventlet_exceptions():
    orig_state = greenpool.DEBUG
    eventlet_debug.hub_exceptions(False)
    try:
        yield
    finally:
        eventlet_debug.hub_exceptions(orig_state)
예제 #5
0
 def test_everything(self):
     debug.hub_exceptions(True)
     debug.hub_exceptions(False)
     debug.tpool_exceptions(True)
     debug.tpool_exceptions(False)
     debug.hub_listener_stacks(True)
     debug.hub_listener_stacks(False)
     debug.hub_timer_stacks(True)
     debug.hub_timer_stacks(False)
     debug.format_hub_listeners()
     debug.format_hub_timers()
예제 #6
0
 def test_everything(self):
     debug.hub_exceptions(True)
     debug.hub_exceptions(False)
     debug.tpool_exceptions(True)
     debug.tpool_exceptions(False)
     debug.hub_listener_stacks(True)
     debug.hub_listener_stacks(False)
     debug.hub_timer_stacks(True)
     debug.hub_timer_stacks(False)
     debug.format_hub_listeners()
     debug.format_hub_timers()
예제 #7
0
 def __init__(self, conf_file, worker_class, **kwargs):
     section_name = 'event-agent'
     self.conf = read_conf(conf_file, section_name)
     self.logger = get_logger(
         self.conf, verbose=kwargs.pop('verbose', False))
     redirect_stdio(self.logger)
     drop_privileges(self.conf.get('user', 'openio'))
     self.num_workers = int_value(self.conf.get('workers'), CPU_COUNT)
     self.worker_class = worker_class
     self.workers = {}
     self.sig_queue = []
     debug.hub_exceptions(True)
예제 #8
0
파일: agent.py 프로젝트: mtanlee/oio-sds
 def __init__(self, conf_file, worker_class, **kwargs):
     section_name = 'event-agent'
     self.conf = read_conf(conf_file, section_name)
     self.logger = get_logger(self.conf,
                              verbose=kwargs.pop('verbose', False))
     redirect_stdio(self.logger)
     drop_privileges(self.conf.get('user', 'openio'))
     self.num_workers = int_value(self.conf.get('workers'), CPU_COUNT)
     self.worker_class = worker_class
     self.workers = {}
     self.sig_queue = []
     debug.hub_exceptions(True)
예제 #9
0
    for i in xrange(CONCURRENCY):
        sock, addr = server_sock.accept()
        pool.spawn_n(reader, sock)

def heavy_accepter(server_sock, pool):
    for i in xrange(CONCURRENCY):
        sock, addr = server_sock.accept()
        t = threading.Thread(None, reader, "reader thread", (sock,))
        t.start()
        pool.append(t)

import eventlet.green.socket
import eventlet

from eventlet import debug
debug.hub_exceptions(True)

def launch_green_threads():
    pool = eventlet.GreenPool(CONCURRENCY * 2 + 1)
    server_sock = eventlet.green.socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_sock.bind(('localhost', 0))
    server_sock.listen(50)
    addr = ('localhost', server_sock.getsockname()[1])
    pool.spawn_n(green_accepter, server_sock, pool)
    for i in xrange(CONCURRENCY):
        pool.spawn_n(writer, addr, eventlet.green.socket.socket)
    pool.waitall()
       
import threading
import socket       
    
예제 #10
0
 def tearDown(self):
     super(TestServe, self).tearDown()
     from eventlet import debug
     debug.hub_exceptions(True)
예제 #11
0
 def setUp(self):
     super(TestServe, self).setUp()
     from eventlet import debug
     debug.hub_exceptions(False)
예제 #12
0
 def setUp(self):
     super(TestServe, self).setUp()
     debug.hub_exceptions(False)
예제 #13
0
 def tearDown(self):
     super(TestServe, self).tearDown()
     debug.hub_exceptions(True)
예제 #14
0
 def tearDown(self):
     super(TestMultipleListenersCleanup, self).tearDown()
     debug.hub_prevent_multiple_readers(True)
     debug.hub_exceptions(True)
예제 #15
0
 def setUp(self):
     super(TestServe, self).setUp()
     debug.hub_exceptions(False)
예제 #16
0
 def setUp(self):
     super(TestServe, self).setUp()
     from eventlet import debug
     debug.hub_exceptions(False)
예제 #17
0
 def tearDown(self):
     super(TestServe, self).tearDown()
     from eventlet import debug
     debug.hub_exceptions(True)
예제 #18
0
 def tearDown(self):
     super(TestServe, self).tearDown()
     debug.hub_exceptions(True)
예제 #19
0
 def setUp(self):
     super(TestMultipleListenersCleanup, self).setUp()
     debug.hub_prevent_multiple_readers(False)
     debug.hub_exceptions(False)