Permalink
Browse files

call socket.setblocking(0) for haproxy plugin

  • Loading branch information...
Scott Smith
Scott Smith committed Feb 18, 2012
1 parent 2891c42 commit e39555d2e63714948ca9eed3dbc87c33fdf9a15f
Showing with 4 additions and 0 deletions.
  1. +4 −0 haproxy.py
View
@@ -1,4 +1,5 @@
import re
+import select
import socket
from porkchop.plugin import PorkchopPlugin
@@ -32,12 +33,15 @@ def col2stat(self, idx):
def stats(self, sock_path):
try:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ sock.setblocking(0)
sock.connect(sock_path)
sock_data = []
data = ''
sock.send('show stat\n')
+ ready = select.select([sock], [], [], 3)
+ if ready[0]:
while True:
data = sock.recv(1024)
if not data:

0 comments on commit e39555d

Please sign in to comment.