On 05/27/10 02:01, Eduardo Alvarez wrote:
When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
   File "<stdin>", line 1, in<module>
   File "/usr/lib/python2.6/nntplib.py", line 345, in group
     resp = self.shortcmd('GROUP ' + name)
   File "/usr/lib/python2.6/nntplib.py", line 259, in shortcmd
     return self.getresp()
   File "/usr/lib/python2.6/nntplib.py", line 214, in getresp
     resp = self.getline()
   File "/usr/lib/python2.6/nntplib.py", line 206, in getline
     if not line: raise EOFError
EOFError

Running this a *second* time, gives me the following, different error:

Traceback (most recent call last):
   File "<stdin>", line 1, in<module>
   File "/usr/lib/python2.6/nntplib.py", line 345, in group
     resp = self.shortcmd('GROUP ' + name)
   File "/usr/lib/python2.6/nntplib.py", line 258, in shortcmd
     self.putcmd(line)
   File "/usr/lib/python2.6/nntplib.py", line 198, in putcmd
     self.putline(line)
   File "/usr/lib/python2.6/nntplib.py", line 193, in putline
     self.sock.sendall(line)
   File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

As this is a broken pipe, I reconnect to the server, the same way as
before. When I *then* retrieving the newsgroup's info, I get no errors.

I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

yours,


Here is how I approached it:

# Lets see first if the server is available
[mar...@aspire8930 /usr/home/martin]$ telnet nntp.aioe.org nntp
Trying 94.75.214.90...
Connected to nntp.aioe.org.
Escape character is '^]'.
200 nntp.aioe.org InterNetNews NNRP server INN 2.5.1 ready (posting ok)
^]
telnet> quit
Connection closed.
# Okidoki seems fine

# lets fire up python
[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Apr  9 2010, 12:45:45)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import nntplib
>>> s = nntplib.NNTP('nntp.aioe.org')
>>> s.group('comp.lang.python')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/nntplib.py", line 345, in group
    resp = self.shortcmd('GROUP ' + name)
  File "/usr/local/lib/python2.6/nntplib.py", line 259, in shortcmd
    return self.getresp()
  File "/usr/local/lib/python2.6/nntplib.py", line 214, in getresp
    resp = self.getline()
  File "/usr/local/lib/python2.6/nntplib.py", line 206, in getline
    if not line: raise EOFError
EOFError
# Ah yes the same error, good at least the same problem.

# Lets see what the docs has to say about it.
>>> help(nntplib.NNTP)
Help on class NNTP in module nntplib:

class NNTP
 |  # The class itself
 |
 |  Methods defined here:
 |
| __init__(self, host, port=119, user=None, password=None, readermode=None, usenetrc=True)
 |      Initialize an instance.  Arguments:
 |      - host: hostname to connect to
 |      - port: port to connect to (default the standard NNTP port)
 |      - user: username to authenticate with
 |      - password: password to use with username
 |      - readermode: if true, send 'mode reader' command after
 |                    connecting.
 |
 |      readermode is sometimes necessary if you are connecting to an
 |      NNTP server on the local machine and intend to call
 |      reader-specific comamnds, such as `group'.  If you get
 |      unexpected NNTPPermanentErrors, you might need to set
 |      readermode.
 |
# readermode seems to be worth a shot:
>>> s = nntplib.NNTP('nntp.aioe.org', readermode=True)
>>> s.group('comp.lang.python')
('211 2444 50405 52862 comp.lang.python', '2444', '50405', '52862', 'comp.lang.python')
>>>
# okidoki got something, but I have no idea why, perhaps need to have
# a look at the source to see what that mode actually does.
# But then again I think it would be better if you would do
# that and if you are feeling generous might contribute back
# to this thread what your findings where.

--
mph



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to