Revision: 3213
http://spambayes.svn.sourceforge.net/spambayes/?rev=3213&view=rev
Author: montanaro
Date: 2008-11-25 03:56:06 +0000 (Tue, 25 Nov 2008)
Log Message:
-----------
reset refused_count when forking server.
pylint nits.
Modified Paths:
--------------
trunk/spambayes/scripts/sb_bnfilter.py
Modified: trunk/spambayes/scripts/sb_bnfilter.py
===================================================================
--- trunk/spambayes/scripts/sb_bnfilter.py 2008-11-25 03:50:08 UTC (rev
3212)
+++ trunk/spambayes/scripts/sb_bnfilter.py 2008-11-25 03:56:06 UTC (rev
3213)
@@ -157,40 +157,44 @@
if error:
sys.exit(error)
-def make_socket(server_options, file):
+def make_socket(server_options, filename):
refused_count = 0
no_server_count = 0
while 1:
try:
- s = socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
- s.connect(file)
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.connect(filename)
except socket.error,e:
if e[0] == errno.EAGAIN:
# baaah
pass
- elif e[0] == errno.ENOENT or not os.path.exists(file):
- # We need to check os.path.exists for use on operating systems
that
- # never return ENOENT; linux 2.2.
+ elif e[0] == errno.ENOENT or not os.path.exists(filename):
+ # We need to check os.path.exists for use on operating
+ # systems that never return ENOENT; linux 2.2.
#
# no such file.... no such server. create one.
no_server_count += 1
- if no_server_count>4:
+ if no_server_count > 4:
raise
+ # Reset refused count to start the sleep process over.
+ # Otherwise we run the risk of waiting a *really* long time
+ # and/or hitting the refused_count limit.
+ refused_count = 0
fork_server(server_options)
elif e[0] == errno.ECONNREFUSED:
# socket file exists but noone listening.
refused_count += 1
- if refused_count == 6:
+ if refused_count == 4:
# We have been waiting ages and still havent been able
# to connect. Maybe that socket file has got
# orphaned. remove it, wait, and try again. We need to
# allow enough time for sb_bnserver to initialise the
# rest of spambayes
try:
- os.unlink(file)
+ os.unlink(filename)
except EnvironmentError:
pass
- elif refused_count>6:
+ elif refused_count > 6:
raise
else:
raise # some other problem
@@ -212,9 +216,9 @@
os.setsid()
# Use exec rather than import here because eventually it may be nice to
# reimplement this one file in C
- os.execv(sys.executable,[sys.executable,
- os.path.join(os.path.split(sys.argv[0])[0],
- 'sb_bnserver.py') ]+options)
+ os.execv(sys.executable, [sys.executable,
+ os.path.join(os.path.split(sys.argv[0])[0],
+ 'sb_bnserver.py') ]+options)
# should never get here
sys._exit(1)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins