Exemple #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()
Exemple #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())
Exemple #3
0
def quiet_eventlet_exceptions():
    orig_state = greenpool.DEBUG
    eventlet_debug.hub_exceptions(False)
    try:
        yield
    finally:
        eventlet_debug.hub_exceptions(orig_state)
Exemple #4
0
def quiet_eventlet_exceptions():
    orig_state = greenpool.DEBUG
    eventlet_debug.hub_exceptions(False)
    try:
        yield
    finally:
        eventlet_debug.hub_exceptions(orig_state)
Exemple #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()
Exemple #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()
Exemple #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)
Exemple #8
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)
Exemple #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       
    
Exemple #10
0
 def tearDown(self):
     super(TestServe, self).tearDown()
     from eventlet import debug
     debug.hub_exceptions(True)
Exemple #11
0
 def setUp(self):
     super(TestServe, self).setUp()
     from eventlet import debug
     debug.hub_exceptions(False)
 def setUp(self):
     super(TestServe, self).setUp()
     debug.hub_exceptions(False)
 def tearDown(self):
     super(TestServe, self).tearDown()
     debug.hub_exceptions(True)
Exemple #14
0
 def tearDown(self):
     super(TestMultipleListenersCleanup, self).tearDown()
     debug.hub_prevent_multiple_readers(True)
     debug.hub_exceptions(True)
 def setUp(self):
     super(TestServe, self).setUp()
     debug.hub_exceptions(False)
 def setUp(self):
     super(TestServe, self).setUp()
     from eventlet import debug
     debug.hub_exceptions(False)
 def tearDown(self):
     super(TestServe, self).tearDown()
     from eventlet import debug
     debug.hub_exceptions(True)
 def tearDown(self):
     super(TestServe, self).tearDown()
     debug.hub_exceptions(True)
Exemple #19
0
 def setUp(self):
     super(TestMultipleListenersCleanup, self).setUp()
     debug.hub_prevent_multiple_readers(False)
     debug.hub_exceptions(False)