gmailgem / gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Other
397 stars 119 forks source link

Hanging — After Many Emails #180

Closed abhillman closed 4 years ago

abhillman commented 9 years ago

Thank you kindly for maintaining this gem.

I am doing something like the following (fairly standard):

Gmail.connect(EMAIL_ADDRESS, PASSWORD) do |gmail|
    error_emails = gmail.inbox.emails(:to => 'errors@example.com')
    error_emails.each do |email|
        # print a log message
        # save the email body to file
    end
end

After about 300 emails, the Ruby hung for about an hour before I killed the process. My question is:

Some notes:

Any ideas? It is possible this is due to JRuby. Thank you again for maintaining this gem!

johnnyshields commented 9 years ago

118k mails is quite a lot--are you pulling them all into memory? Can you check your system's resource utilization?

johnnyshields commented 9 years ago

@abhillman please provide more details here or will close the issue. On the surface it looks like you're trying to pull to many emails in one query.

lg commented 8 years ago

@abhillman this is likely because you're downloading all emails in memory before going through them. i'd recommend an approach similar to what i did here: https://github.com/gmailgem/gmail/issues/219

johnnyshields commented 4 years ago

As of version 0.7.0 (Aug 19, 2018) this gem is officially deprecated and will no longer be maintained. Please instead use Google's official Gmail API Ruby Client, which uses the Gmail API rather than IMAP and has significantly better performance and reliability.