This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Stuck/hang when reading ssl object
Type: behavior Stage:
Components: None Versions: Python 2.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, seamus.mckenna
Priority: normal Keywords:

Created on 2012-07-27 16:01 by seamus.mckenna, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg166579 - (view) Author: Seamus McKenna (seamus.mckenna) Date: 2012-07-27 16:01
My python scripting has been running for several weeks periodically sending out emails.  However the script has been stuck for the last 24 hrs.  No parts of my script have been executed in this period.

On terminating the script via ctrl-c, I can see that the script is stuck with the python ssl library. See below;

-----------------------------------------------------------------
File "/export2/home/intregress/LabEnv210/lab/int_lib/int_tools/PTM_COMMON/user.py", line 4277, in email
    mailServer.sendmail(gmail_user, to, msg.as_string())
  File "/tools/ACTIVESTATE/python/2.7.1.3/x86/lib/python2.7/smtplib.py", line 713, in sendmail
    (code,resp) = self.data(msg)
  File "/tools/ACTIVESTATE/python/2.7.1.3/x86/lib/python2.7/smtplib.py", line 482, in data
    (code,msg)=self.getreply()
  File "/tools/ACTIVESTATE/python/2.7.1.3/x86/lib/python2.7/smtplib.py", line 338, in getreply
    line = self.file.readline()
  File "/tools/ACTIVESTATE/python/2.7.1.3/x86/lib/python2.7/smtplib.py", line 177, in readline
    chr = self.sslobj.read(1)
  File "/tools/ACTIVESTATE/python/2.7.1.3/x86/lib/python2.7/ssl.py", line 138, in read
    return self._sslobj.read(len)
-------------------------------------------------------------------
msg166588 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-27 17:38
Well, the traceback shows it's stuck trying to read from the network. It doesn't mean it's stuck in the ssl library; unless your script was taking 100% CPU when you killed it, it was most likely waiting for the peer (a SMTP server, I guess) to respond.

One suggestion would be to add a timeout to the SMTP connection. You can also use set_debuglevel() to get more detailed info about what's happening.
msg166870 - (view) Author: Seamus McKenna (seamus.mckenna) Date: 2012-07-30 09:46
Thankyou for update.  Script was not using 100% cpu. I will add SMTP timeout and increase debuglevel() within the function should this reoccur.
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59675
2012-07-30 09:46:37seamus.mckennasetstatus: open -> closed

messages: + msg166870
2012-07-27 17:38:15pitrousetnosy: + pitrou
messages: + msg166588
2012-07-27 16:01:10seamus.mckennacreate