From b46075bb80e3610556fe38e437a0ceca71eb0909 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 2 Aug 2009 23:12:44 -0700 Subject: [PATCH] Cleanup --- eventlet/hubs/hub.py | 11 ++++++----- eventlet/hubs/libevent.py | 3 +++ tests/greenio_test.py | 17 ----------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index 6fb6307..c455970 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -53,17 +53,17 @@ class BaseHub(object): 'exit': [], } - def add_reader(self, fileno, reader): + def add_reader(self, fileno, read_cb): """ Signals an intent to read from a particular file descriptor. The *fileno* argument is the file number of the file of interest. - The *reader* argument is the greenlet which will be switched to when the file + The *read_cb* argument is the callback which will be called when the file is ready for reading. """ - self.readers[fileno] = reader + self.readers[fileno] = read_cb - def add_writer(self, fileno, writer): + def add_writer(self, fileno, write_cb): """ Signals an intent to write to a particular file descriptor. The *fileno* argument is the file number of the file of interest. @@ -71,7 +71,8 @@ class BaseHub(object): The *write_cb* argument is the callback which will be called when the file is ready for writing. """ - self.writers[fileno] = writer + + self.writers[fileno] = write_cb def closed(self, fileno): """ Clean up any references so that we don't try and diff --git a/eventlet/hubs/libevent.py b/eventlet/hubs/libevent.py index 3948f69..201a053 100644 --- a/eventlet/hubs/libevent.py +++ b/eventlet/hubs/libevent.py @@ -64,6 +64,9 @@ class Hub(object): self.signal_exc_info = None self.signal(2, lambda signalnum, frame: self.greenlet.parent.throw(KeyboardInterrupt)) self.events_to_add = [] + + def closed(self, fd): + pass def switch(self): cur = api.getcurrent() diff --git a/tests/greenio_test.py b/tests/greenio_test.py index 59ed697..bc12c5f 100644 --- a/tests/greenio_test.py +++ b/tests/greenio_test.py @@ -104,42 +104,25 @@ class TestGreenIo(TestCase): listener = api.tcp_listener(('127.0.0.1', 0)) def send_large(sock): - print "about to send large" # needs to send enough data that trampoline() is called sock.sendall('*' * 100000) - print "sent large" def server(): (client, addr) = listener.accept() - print "accepted" # start reading, then, while reading, start writing. # the reader should not hang forever api.spawn(send_large, client) - print "spawned send_large" api.sleep(0) # allow send_large to execute up to the trampoline - print "slept" result = client.recv(1000) - print "received" assert result == 'hello world', result server_evt = coros.execute(server) - print "spawned server" client = api.connect_tcp(('127.0.0.1', listener.getsockname()[1])) api.spawn(client.makefile().read) - print "spawned read" api.sleep(0) - print "slept 2" client.send('hello world') - print "sent hello world" - - # close() hangs client.close() - print "closed" - - # this tests "full duplex" bug which is still not fixed server_evt.wait() - print "waited" - def test_server(sock, func, *args):