Inconsistent SMTP/Gmail connection drop

Astley Le Jasper astley.lejasper at gmail.com
Thu Aug 4 09:54:26 CEST 2011


Thanks for those suggestions.

I tried something last night before I got your ideas.

1. I added a line to send a copy of the report just to me, 2 lines
before the line where it emails the report to all the recipients.
2. I also added a timer.sleep(5) pause just before the line that
emails the reports to all the recipients.

So the order was:

a) Send the full report just to me .... FAILED.
b) Pause for 5 seconds.
c) Send the full report to all 4 recipients ... WORKED.
d) Send the log file just to me ... WORKED.

So ... what looks like may be happening is that something might still
be locking the file. In which case i'll try again without the test
email to me. And/or perhaps send a test email without the attachment
before the main report to see if that gets through, to see if the
connection with gmail is actually really connected.

See also below...

> 1) You might see if there's something about the size of the message - is it
> bigger after collecting data all night?  Is google disconnecting after a
> maximum amount of data is transferred?

I don't think so. The test message I mentioned above got through and
the attachment was identical (320kb or abouts)

> 2) You might try sending a tiny test message at the beginning, just to
> yourself, and seeing if that has the problem

As above.

> 3) You might try running your script under a system call tracer:
> http://stromberg.dnsalias.org/~dstromberg/debugging-with-syscall-tracers.html
> - and inspecting the list of syscalls and their return codes near when the
> process terminates

Ouch. Looks complicated!
;-)

> 4) I get disconnects from gmail once in a while too, especially when
> downloading a large list of new message headers; I've been just coding
> around it by making my code idempotent and otherwise restartable.  This
> seems to happen with both 2.x and 3.x, so I assume it's not really related
> to the Python version, but I suppose I should try it on PyPy or Jython
> someday.  Note that the error message in 3.x was better than in 2.x.

I was thinking that perhaps I could put a loop in that tests if the
email goes through, and if not, pauses for a few seconds and then
tries again.



More information about the Python-list mailing list