From fd898c9eacf35fd3d6b2fe647da11100be24a8de Mon Sep 17 00:00:00 2001 From: Arturo 'Buanzo' Busleiman Date: Sun, 30 Aug 2009 13:27:52 +0000 Subject: [PATCH] added python version detection to asyncore.loop(use_poll=True|False) git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_8@736 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- server/asyncserver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/asyncserver.py b/server/asyncserver.py index b3f8ea52..fedfdd30 100644 --- a/server/asyncserver.py +++ b/server/asyncserver.py @@ -133,7 +133,12 @@ class AsyncServer(asyncore.dispatcher): self.__init = True # TODO Add try..catch # There's a bug report for Python 2.6/3.0 that use_poll=True yields some 2.5 incompatibilities: - asyncore.loop(use_poll = False) # fixes the "Unexpected communication problem" issue on Python 2.6. + if (sys.version_info[0] == 2 and sys.version_info[1] == 6) or (sys.version_info[0] == 3): # if python 2.6 or 3.*... + logSys.debug("Detected Python 2.6 or 3.*. asyncore.loop() not using poll") + asyncore.loop(use_poll = False) # fixes the "Unexpected communication problem" issue on Python 2.6 and 3.0 + else: + logSys.debug("NOT Python 2.6/3.* - asyncore.loop() using poll") + asyncore.loop(use_poll = True) ## # Stops the communication server.