smtplib upload progress

Discussion in 'Python' started by Guyon Morée, Oct 19, 2009.

  1. Guyon Morée

    Guyon Morée Guest

    Hi,

    I wanted to use smtplib to send a bunch of files. All good, except I
    cant monitor the upload progress as far as I can see.

    So I monkey patched the SMTP.sendall method, which chops up the data
    and keeps calling a provided callback for every chunk of data sent.

    This feels kind of dirty and I was wondering what my other options are
    to tackle this seemingly simple problem.

    thanx,

    Guyon Moree
     
    Guyon Morée, Oct 19, 2009
    #1
    1. Advertising

  2. En Mon, 19 Oct 2009 19:33:50 -0300, Guyon Morée <>
    escribió:

    > I wanted to use smtplib to send a bunch of files. All good, except I
    > cant monitor the upload progress as far as I can see.
    >
    > So I monkey patched the SMTP.sendall method, which chops up the data
    > and keeps calling a provided callback for every chunk of data sent.
    >
    > This feels kind of dirty and I was wondering what my other options are
    > to tackle this seemingly simple problem.


    (there is no sendall method in SMTP, but send)
    Looks like there is no other way... perhaps I'd have overriden data()
    instead of send(), but it's as dirty as yours, one has to duplicate the
    original code.
    I don't know how often the need arises or how useful would this be to
    others, but you could submit a patch to http://bugs.python.org/

    --
    Gabriel Genellina
     
    Gabriel Genellina, Oct 20, 2009
    #2
    1. Advertising

  3. On Tue, 20 Oct 2009 00:24:33 -0300, "Gabriel Genellina"
    <> declaimed the following in
    gmane.comp.python.general:

    > En Mon, 19 Oct 2009 19:33:50 -0300, Guyon Morée <>
    > escribió:
    >
    > > I wanted to use smtplib to send a bunch of files. All good, except I
    > > cant monitor the upload progress as far as I can see.
    > >
    > > So I monkey patched the SMTP.sendall method, which chops up the data
    > > and keeps calling a provided callback for every chunk of data sent.
    > >
    > > This feels kind of dirty and I was wondering what my other options are
    > > to tackle this seemingly simple problem.

    >
    > (there is no sendall method in SMTP, but send)
    > Looks like there is no other way... perhaps I'd have overriden data()
    > instead of send(), but it's as dirty as yours, one has to duplicate the
    > original code.
    > I don't know how often the need arises or how useful would this be to
    > others, but you could submit a patch to http://bugs.python.org/
    >

    I'd suspect not very often given the original store&forward scheme
    of SMTP... Especially when mail clients used to just spool a message
    file for a background daemon to attempt to periodically send... On such
    a system, the client "send" is practically instantaneous, and the real
    message send may take a few days to complete if the daemon can't get a
    valid connection for the destination address.

    > --
    > Gabriel Genellina

    --
    Wulfraed Dennis Lee Bieber KD6MOG
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Oct 21, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    3
    Views:
    2,471
  2. Kenneth Keeley

    File Upload Progress

    Kenneth Keeley, Oct 21, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,395
    Kenneth Keeley
    Oct 21, 2003
  3. Jeff S

    Show Upload Progress

    Jeff S, Apr 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    616
    Jeff S
    Apr 6, 2004
  4. Charlie Zhang
    Replies:
    3
    Views:
    1,342
    Paul Lutus
    Aug 16, 2004
  5. Evan
    Replies:
    3
    Views:
    518
Loading...

Share This Page