Author: ritchiem Date: Wed Oct 28 15:35:50 2009 New Revision: 830610 URL: http://svn.apache.org/viewvc?rev=830610&view=rev Log: Modified to work on Windows; fixes QPID-2149.
Modified: qpid/branches/0.5.x-dev/qpid/python/qpid/selector.py qpid/branches/0.5.x-dev/qpid/python/tests/connection.py Modified: qpid/branches/0.5.x-dev/qpid/python/qpid/selector.py URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/python/qpid/selector.py?rev=830610&r1=830609&r2=830610&view=diff ============================================================================== --- qpid/branches/0.5.x-dev/qpid/python/qpid/selector.py (original) +++ qpid/branches/0.5.x-dev/qpid/python/qpid/selector.py Wed Oct 28 15:35:50 2009 @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. # -import atexit, os, time +import atexit, time, socket from compat import select, set from threading import Thread, Lock @@ -41,20 +41,20 @@ class Sink: - def __init__(self, fd): - self.fd = fd + def __init__(self, sock): + self.sock = sock def fileno(self): - return self.fd + return self.sock.fileno() def reading(self): return True def readable(self): - os.read(self.fd, 65536) + self.sock.recv(65536) def __repr__(self): - return "Sink(%r)" % self.fd + return "Sink(%r)" % self.sock.fileno() class Selector: @@ -78,13 +78,20 @@ self.selectables = set() self.reading = set() self.writing = set() - self.wait_fd, self.wakeup_fd = os.pipe() - self.reading.add(Sink(self.wait_fd)) + listener = socket.socket() + listener.bind(('', 0)) + listener.listen(1) + me_ip, me_port = listener.getsockname() + self.wakeup_sock = socket.socket() + self.wakeup_sock.connect(("127.0.0.1", me_port)) + self.wait_sock, me = listener.accept() + listener.close() + self.reading.add(Sink(self.wait_sock)) self.stopped = False self.thread = None def wakeup(self): - os.write(self.wakeup_fd, "\0") + self.wakeup_sock.send("\0") def register(self, selectable): self.selectables.add(selectable) Modified: qpid/branches/0.5.x-dev/qpid/python/tests/connection.py URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/python/tests/connection.py?rev=830610&r1=830609&r2=830610&view=diff ============================================================================== --- qpid/branches/0.5.x-dev/qpid/python/tests/connection.py (original) +++ qpid/branches/0.5.x-dev/qpid/python/tests/connection.py Wed Oct 28 15:35:50 2009 @@ -91,11 +91,11 @@ def tearDown(self): self.running = False - connect("0.0.0.0", PORT).close() + connect("127.0.0.1", PORT).close() self.server.join(3) def connect(self, **kwargs): - return Connection(connect("0.0.0.0", PORT), **kwargs) + return Connection(connect("127.0.0.1", PORT), **kwargs) def test(self): c = self.connect() --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org