Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout exeption message while running gmail.py #21

Open
JBPressac opened this issue Jan 13, 2014 · 11 comments
Open

Timeout exeption message while running gmail.py #21

JBPressac opened this issue Jan 13, 2014 · 11 comments

Comments

@JBPressac
Copy link

Hello,
I have a problem when I execute the gmail.py script (ch03/gmail/gmail.py): the email collection does not occur and the "Timeout exception occured!" message is displayed (tested on Mac OS X 10.6 and Linux Debian in a virtual machine running Windows).

Note that the timeout error is displayed even when running the script without specifying any parameters (to display the usage message).
Jean-Baptiste

@mathias
Copy link

mathias commented Feb 2, 2014

I'm also seeing this.

@mathias
Copy link

mathias commented Feb 2, 2014

I'm wondering whether plaintext authentication (self.imap.login(username, password) in gmail_slurper.py) no longer works for Gmail?

Anyone else having success with this script?

Edit: some notes

Plaintext auth is still allowed, however, I had to pull the self.imap.login() call out of the try block to see a different exception bubbling up:

imaplib.error: [ALERT] Application-specific password required: http://support.google.com/accounts/bin/answer.py?answer=185833 (Failure)

It's probaby worth noting that users will have to create an application-specific password if they have 2-factor auth turned on, either in the help text for the command or in errata?

That said, this sleuthing doesn't seem to have eliminated the Timeout exception or allowed me to download my gmail.

@cwarny
Copy link

cwarny commented Feb 6, 2014

I have the same issue. Even after creating an app-specific password. It seems like the way the TimeoutException class is defined, whenever the gmail_slurper.py file is imported in a script, an error will be raised...

@rjurney
Copy link
Owner

rjurney commented Feb 6, 2014

The timeout exception shouldn't stop the script - it merely reconnects. Let
me look into this...

On Thu, Feb 6, 2014 at 2:39 PM, Cédric Warny [email protected]:

I have the same issue. Even after creating an app-specific password

Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-34383026
.

Russell Jurney twitter.com/rjurney [email protected] datasyndrome.com

@cwarny
Copy link

cwarny commented Feb 7, 2014

Commenting out the following line in gmail_slurper.py solved it for me:

sys.stderr.write("Timeout exception occurred!\n")

Looks like writing a stderr out stops the script.

@rjurney
Copy link
Owner

rjurney commented Feb 7, 2014

That can't be the case... are you sure the script is stopping? It is
actually normal for the script to throw a timeout exception as soon as it
starts. I've never figured out why, but it just keeps going.

On Fri, Feb 7, 2014 at 8:23 AM, Cédric Warny [email protected]:

Commenting out the following line in gmail_slurper.py solved it for me:

sys.stderr.write("Timeout exception occurred!\n")

Looks like writing a stderr out stops the script.

Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-34461255
.

Russell Jurney twitter.com/rjurney [email protected] datasyndrome.com

@krwaters
Copy link

krwaters commented Feb 7, 2014

I've successfully run the script.

Just as Russell describes ... I get the timeout exception. The script
continues running after displaying message.

Kendall Waters
On Feb 7, 2014 9:34 AM, "Russell Jurney" [email protected] wrote:

That can't be the case... are you sure the script is stopping? It is
actually normal for the script to throw a timeout exception as soon as it
starts. I've never figured out why, but it just keeps going.

On Fri, Feb 7, 2014 at 8:23 AM, Cédric Warny [email protected]:

Commenting out the following line in gmail_slurper.py solved it for me:

sys.stderr.write("Timeout exception occurred!\n")

Looks like writing a stderr out stops the script.

Reply to this email directly or view it on GitHub<
https://github.com/rjurney/Agile_Data_Code/issues/21#issuecomment-34461255>

.

Russell Jurney twitter.com/rjurney [email protected]
datasyndrome.com

Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-34477746
.

@mathias
Copy link

mathias commented Feb 8, 2014

I was able to eventually get it to run by commenting out the exception try-catch blocks and fixing whatever Gmail is sending back as an error (first the app-specific password, then something else.)

You might want to try experimenting with that approach as a way to get past it; I understand the reason for the try-catch blocks and don't think the main code needs to change for that since it seems like a subset of users have this problem.

@davidjmurray
Copy link

I have/had a similar problem as documented here. As I seldom use my gmail account, I had only 2 emails in the Inbox. The slurper program would only read one and then stop. The output was only a dict definition within the part-1.avro file - no email data was added.

Reading the emails individually, I was able to read the 1st one, but the 2nd one - ID of 2 - returned:
"Problem fetching email ID: 2 - CHARSET" and stops.

It appeared that I had weird/corrupted 2nd email (or something) which I deleted and then composed another to myself. This enabled the slurper to add the 1st email to the avro file, but not the 2nd.

I then composed a 3rd email to myself. The slurper added the first 2 emails to the avro file, but not the 3rd. It seems to be losing the last email i.e. prematurely exiting.

At all times, the slurper counts the total number of emails correctly in the ongoing output to the screen.

@navarq
Copy link

navarq commented Aug 13, 2014

changing lines 83 and 84 to:

    if hasattr(signal, 'SIGALRM'):
      signal.signal(signal.SIGALRM, timeout_handler)
    if hasattr(signal, 'alarm'):
      signal.alarm(30) # triger alarm in 30 seconds
# from
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(30) # triger alarm in 30 seconds

in gmail_slurpy.py works for me on my windows machine.

the signal object does not have the attributes sigalrm nor alarm

@rjurney
Copy link
Owner

rjurney commented Aug 14, 2014

Can you please send a pull request, and I'll merge it?

On Wed, Aug 13, 2014 at 3:29 AM, Basil Muhammad [email protected]
wrote:

changing lines 83 and 84 to:

if hasattr(signal, 'SIGALRM'):
  signal.signal(signal.SIGALRM, timeout_handler)
if hasattr(signal, 'alarm'):
  signal.alarm(30) # triger alarm in 30 seconds# fromsignal.signal(signal.SIGALRM, timeout_handler)signal.alarm(30) # triger alarm in 30 seconds

in gmail_slurpy.py works for me on my windows machine.

the signal object does not have the attributes sigalrm nor alarm


Reply to this email directly or view it on GitHub
#21 (comment)
.

Russell Jurney twitter.com/rjurney [email protected] datasyndrome.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants