[Spambayes-checkins] spambayes/scripts sb_server.py,1.40,1.41

Tony Meyer anadelonbrin at users.sourceforge.net
Mon Feb 7 23:57:40 CET 2005


Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14204/scripts

Modified Files:
	sb_server.py 
Log Message:
Move the ensureDir function to storage, as many scripts use it.

Fix [ 1113863 ] sb_tray eats all cpu time
When in non-verbose mode, connection errors are reported only once per hour.

Index: sb_server.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_server.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** sb_server.py	3 Jan 2005 06:51:42 -0000	1.40
--- sb_server.py	7 Feb 2005 22:57:38 -0000	1.41
***************
*** 159,163 ****
          except socket.error, e:
              error = "Can't connect to %s:%d: %s" % (serverName, serverPort, e)
!             print >>sys.stderr, error
              self.lineCallback('-ERR %s\r\n' % error)
              self.lineCallback('')   # "The socket's been closed."
--- 159,180 ----
          except socket.error, e:
              error = "Can't connect to %s:%d: %s" % (serverName, serverPort, e)
!             # Some people have their system setup to check mail very
!             # frequently, but without being clever enough to check whether
!             # the network is available.  If we continually print the
!             # "can't connect" error, we use up lots of CPU and disk space.
!             # To avoid this, if not verbose only print each distinct error
!             # once per hour.
!             # See also: [ 1113863 ] sb_tray eats all cpu time
!             now = time.time()
!             then = time.time() - 3600
!             if error not in state.reported_errors or \
!                options["globals", "verbose"] or \
!                state.reported_errors[error] < then:
!                 print >>sys.stderr, error
! 
!                 # Record this error in the list of ones we have seen this
!                 # session.
!                 state.reported_errors[error] = now
! 
              self.lineCallback('-ERR %s\r\n' % error)
              self.lineCallback('')   # "The socket's been closed."
***************
*** 745,748 ****
--- 762,768 ----
              sys.exit()
  
+         # Remember reported errors.
+         self.reported_errors = {}
+ 
          # Set up the statistics.
          self.totalSessions = 0
***************
*** 861,871 ****
          # so as not to clutter the filesystem.
          if not self.isTest:
-             def ensureDir(dirname):
-                 try:
-                     os.mkdir(dirname)
-                 except OSError, e:
-                     if e.errno != errno.EEXIST:
-                         raise
- 
              # Create/open the Corpuses.  Use small cache sizes to avoid hogging
              # lots of memory.
--- 881,884 ----
***************
*** 873,877 ****
              hc = get_pathname_option("Storage", "ham_cache")
              uc = get_pathname_option("Storage", "unknown_cache")
!             map(ensureDir, [sc, hc, uc])
              if self.gzipCache:
                  factory = GzipFileMessageFactory()
--- 886,890 ----
              hc = get_pathname_option("Storage", "ham_cache")
              uc = get_pathname_option("Storage", "unknown_cache")
!             map(storage.ensureDir, [sc, hc, uc])
              if self.gzipCache:
                  factory = GzipFileMessageFactory()



More information about the Spambayes-checkins mailing list