Sending attachment with Pony pegs my cpu and never completes

21 views
Skip to first unread message

Nels Nelson

unread,
Dec 7, 2014, 11:17:14 AM12/7/14
to pon...@googlegroups.com
Greetings, Forum,-

I am attempting to send an attachment like so.  The attachment is a 190793 byte file in SQL dump format.

I run the following code on a Mac OS X 10.10 system under JRuby 1.7.16 using the pony 1.11 gem.

I can confirm that the sendmail binary is available at /usr/sbin/sendmail.  The content collection step does indeed work, and the status output gets printed out.

However, it begins to peg cpu and never stops.

    begin
      content = open(attachment, 'rb') { |io| io.read }
      basename = File.basename(attachment)
      puts "Sending file #{basename} #{content.length} to #{to}"
      mail = Pony.mail(
        :via  => :smtp,
        :via_options => {
          :address              => 'smtp.gmail.com',
          :port                 => '587',
          :enable_starttls_auto => true,
          :user_name            => 'us...@host.com',
          :password             => 'password',
          :authentication       => :plain,
          :domain               => 'host.com'
        },
        :to        => to,
        :from      => from,
        :subject   => subject,
        :html_body => message,
        :body      => '',
        :attachments => {
          basename => content
        },
        :headers => {
          'Content-Type' => 'multipart/mixed',
          'Content-Transfer-Encoding' => 'base64',
          'Content-Disposition' => 'attachment'
        }
      )
    rescue Exception => ex
      log.error "Error posting email", ex
      return ex.message
    end if defined? Pony


Can anyone help me understand what I am doing incorrectly?

Best regards,
-Nels Nelson

Ben Prew

unread,
Dec 9, 2014, 5:29:39 PM12/9/14
to pon...@googlegroups.com
Nels,

What happens when you run it under ruby not JRuby?  Have you tried using strace on the process?



--

---
You received this message because you are subscribed to the Google Groups "Ponyrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ponyrb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nels Nelson

unread,
Dec 9, 2014, 7:07:07 PM12/9/14
to pon...@googlegroups.com, b...@throwingbones.com
On Tuesday, December 9, 2014 4:29:39 PM UTC-6, Ben Prew wrote:
What happens when you run it under ruby not JRuby?  Have you tried using strace on the process?


Well, crap.  Running it with ruby 2.0 on Mac OS X 10.10 appears to work just fine.

The following code configuration indeed sends e-mail.


I guess I now have to take it up with the JRuby people.  :(

Thank you for your attention.

Best regards,
-Nels




Ben Prew

unread,
Dec 9, 2014, 8:32:08 PM12/9/14
to pon...@googlegroups.com
Nels,

Sorry, I don't run JRuby so don't have a lot of insight for you.  How much free RAM is there when the CPU is pegged?  Possibly a swap issue?

Thanks and good luck

Nels Nelson

unread,
Dec 9, 2014, 10:26:49 PM12/9/14
to pon...@googlegroups.com, b...@throwingbones.com
On Tuesday, December 9, 2014 7:32:08 PM UTC-6, Ben Prew wrote:
How much free RAM is there when the CPU is pegged?  Possibly a swap issue?

I can use the default 512MB heap size for the jvm when running the program with JRuby, or I can set the heap size to 2GB, it makes no difference.

Plenty of ram available on a machine with 16GB of RAM installed.

Thanks again for your attention.

Best regards,
-Nels

Reply all
Reply to author
Forward
0 new messages