diff options
| author | bwarsaw | 2000-03-13 02:34:28 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-03-13 02:34:28 +0000 |
| commit | 46222eaff069f918b6c2447028ac094cadd16009 (patch) | |
| tree | 48bef895d6c0ecd71966b0b35f4de3265653a448 /cron/gate_news | |
| parent | 3d58c2e9c8e24608377b061d20560b74b4216670 (diff) | |
| download | mailman-46222eaff069f918b6c2447028ac094cadd16009.tar.gz mailman-46222eaff069f918b6c2447028ac094cadd16009.tar.zst mailman-46222eaff069f918b6c2447028ac094cadd16009.zip | |
Import nntplib from Mailman.pythonlib package to pick up the 1.5.2+
version of this module.
main(): simplified connection creation, set readermode in constructor.
Diffstat (limited to '')
| -rwxr-xr-x | cron/gate_news | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/cron/gate_news b/cron/gate_news index 8d5cfa315..dc9976659 100755 --- a/cron/gate_news +++ b/cron/gate_news @@ -45,7 +45,6 @@ import string import time import marshal import paths -import nntplib import errno import traceback import socket @@ -57,6 +56,10 @@ from Mailman import LockFile from Mailman import Message from Mailman.Logging.Utils import LogStdErr +# The version we have is from Python 1.5.2+ and fixes the "mode reader" +# problem. +from Mailman.pythonlib import nntplib + # Work around known problems with some RedHat cron daemons import signal signal.signal(signal.SIGCHLD, signal.SIG_DFL) @@ -112,29 +115,20 @@ def main(): mlist = MailList.MailList(name, lock=0) if not mlist.gateway_to_mail: continue - # open up a connection to the gated newsgroup. we want to get the - # watermark for the group in the parent process so that we can safely - # update the gate_watermarks file. we'll actually do the gating in a - # child process, so we do need to open up a new connection for each - # list. + # Open up a "mode reader" connection to the gated newsgroup. We want + # to get the watermark for the group in the parent process so that we + # can safely update the gate_watermarks file. We'll actually do the + # gating in a child process, so we do need to open up a new connection + # for each list. try: - conn = nntplib.NNTP(mlist.nntp_host) + conn = nntplib.NNTP(mlist.nntp_host, readermode=1) except socket.error, e: # couldn't open a socket to the NNTP host. maybe we've got too # many open right now, or the server is unavailable sys.stderr.write('connect to nntp_host failed\n') sys.stderr.write(`e`) break - try: - r,c,f,l,n = conn.group(mlist.linked_newsgroup) - except nntplib.error_perm: - # We got an error 500, probably meaning that the 'group' command - # is not implemented. A likely scenario causing this is when - # running the Mailman gateway on the same machine as the news - # server; the server defaults to news feed mode. We need to set - # the connection to reader mode first. - conn.shortcmd('mode reader') - r,c,f,l,n = conn.group(mlist.linked_newsgroup) + r,c,f,l,n = conn.group(mlist.linked_newsgroup) if not updatewatermarks: # just post the specified messages and be done with it poll_newsgroup(mlist, conn, first, last+1) |
