diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-10-20 17:56:01 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-10-20 17:56:01 +0000 |
commit | db18d33d3bca740454c3c9e6c5e62f8bcc1e70d4 (patch) | |
tree | c2d0d6006b1181f787c3da61bfe77b5b4d487de0 /python | |
parent | fcc8f328bbac4a318dbe8cdead8de256dac8517d (diff) | |
download | qpid-python-db18d33d3bca740454c3c9e6c5e62f8bcc1e70d4.tar.gz |
Modified to work on Windows; fixes QPID-2149.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@827747 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
-rw-r--r-- | python/qpid/selector.py | 25 | ||||
-rw-r--r-- | python/tests/connection.py | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/python/qpid/selector.py b/python/qpid/selector.py index 46052e1108..a7993be0b1 100644 --- a/python/qpid/selector.py +++ b/python/qpid/selector.py @@ -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 Acceptor: 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 @@ class Selector: 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) diff --git a/python/tests/connection.py b/python/tests/connection.py index d340e4e9c1..8c00df56e1 100644 --- a/python/tests/connection.py +++ b/python/tests/connection.py @@ -91,11 +91,11 @@ class ConnectionTest(TestCase): 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() |