473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

poplib - retr() getting stuck

Hi,

I am using poplib's retr() to fetch mails from my gmail account. It
works fine, in some cases it gets stuck inside the retr() method and
does not come out.

From the logs I could find that when retr() is called, it stops
executing further statements, nor does it throw an exceptions but
simply stops. My code is roughly like the foll:

try:
print "1"
mymsg = M.retr(msg_no)
print "2"
except poplib.error_proto, e:
print "exception1"
except Exception, e:
print "exception2"

What can be the reason for this? Can anyone help me.

Thanks
Roopesh
Jun 27 '08 #1
2 2629
En Fri, 20 Jun 2008 04:37:32 -0300, Roopesh <ro*********@gmail.com>
escribió:
I am using poplib's retr() to fetch mails from my gmail account. It
works fine, in some cases it gets stuck inside the retr() method and
does not come out.
Probably the server stopped responding. By default, sockets have no
timeout value set - that is, a recv() call may block forever.
Try using socket.setdefaulttimeout
<http://docs.python.org/lib/module-socket.htmlbefore creating the
connection, or search this group for past responses to this same problem.

--
Gabriel Genellina

Jun 27 '08 #2
Thanks for the help.

At present I have modified the poplib code as follows (In POP3 and
POP3_SSL classes): Is it the correct way?

def __init__(self, host, port = POP3_PORT):
self.host = host
self.port = port
msg = "getaddrinfo returns an empty list"
self.sock = None

socket.setdefaulttimeout(30)

for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(af, socktype, proto)
self.sock.connect(sa)
except socket.error, msg:

Thanks
Roopesh
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rybread | last post by:
Real quick, I have account X and I want a python script that goes in and looks for emails sent from Y and then to save them. i'm trying to go off the swen killer I have listed below (which i took...
2
by: brettk | last post by:
Hello All, Here's what I'm trying to do: I need to connect to a pop3 server, download all messages, and copy all of the attachments into a specific directory. The actual email message is...
2
by: Steve Greenland | last post by:
For the poplib.POP3 object, docs say: list() Request message list, result is in the form (response, ). If which is set, it is the message to list. But (I've folded the long line): Python...
0
by: Frank Churchill | last post by:
Has anyone used poplib and popfile together? I've tried everything I can think of to specify SRVR in poplib: "127.0.0.1:8081" "127.0.0.1,port=8081" "localhost:8081" "localhost,port=8081" ...
4
by: SuperHik | last post by:
Hi! I want to connect to gmail but... It requires SSL so I worte: Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Python24\lib\poplib.py", line 359, in...
3
by: EuGeNe Van den Bulke | last post by:
Hi there, I am trying to use the poplib library to get emails using the retr method. The small program bellow works but the message aren't flagged as read which puzzles me. I believe the pop...
1
by: erikcw | last post by:
Hi, I keep getting this error from poplib: (error_proto(-ERR EOF) line 121 poplib.py Does this mean the connection has timed out? What can I do to deal with it? Thanks! Erik
4
by: Jean-Claude Neveu | last post by:
Hello, I am writing a Python program to check email using POP3. I've tried the sample code from python.org, and it works great. In other words, the code below successfully prints out my emails....
2
by: SteveC | last post by:
Hello, I am trying to use POP3_SSL class of the poplib module to read email from my gmail account. I can connect just fine using the example here http://www.python.org/doc/lib/pop3-example.html...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.