In FakeStatsd, use select() rather than poll()
The poll() system call is not available on all systems (like OS X, for
example), causing the test suite to fail. This change replaces poll()
with select(), which is more portable. With this change the test suite passes
under OS X.
Change-Id: I3ad716b127c8781d8dbf870b0f0c0e1162f264d1
Reviewed-on: https://review.openstack.org/28126
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 26c2710..508af42 100644
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -655,17 +655,15 @@
def run(self):
while True:
- poll = select.poll()
- poll.register(self.sock, select.POLLIN)
- poll.register(self.wake_read, select.POLLIN)
- ret = poll.poll()
- for (fd, event) in ret:
- if fd == self.sock.fileno():
+ read_ready = select.select([self.sock, self.wake_read], [], [])[0]
+ for sock in read_ready:
+ if sock is self.sock:
data = self.sock.recvfrom(1024)
if not data:
return
self.stats.append(data[0])
- if fd == self.wake_read:
+ else:
+ # wake_read
return
def stop(self):