nntplib body question

Paul Rubin http
Wed Jun 4 05:55:42 EDT 2003


"Peter Melchart" <peter at melchart.com> writes:
> > Well, you could drop the connection after you've read enough lines.
> > If it's a several megabyte message and you want just a few lines, that
> > may be a win.
> 
> that's exactly what i want to do. but when i call nntpconn.body(id) it
> retrieves the whole body. how can i cut the connection after a certain
> amount of bytes. a kind of network-callback would be nice that is called
> after reading 1K or so, so i can skip the rest after 1 read 100 lines or
> so...
> is there anything like that ?
> the thing is, that i dont want to retrieve the whole article.

According to the docs, you can pass a file-like object to
nntpcon.body(id) and it will write lines of the body to that file
object.  So maybe you can implement some class that accepts however
many lines you want and then raises an exception.

If all else fails, you can modify nntplib to do what you need.




More information about the Python-list mailing list