Pop3 Ruby calls cause loss of MySQL connection

Any help is very much appreciated.

MySQL 5.0 and Rails 1.2.6

I have a Deamon process that looks for incoming mail using pop3. It all works smashing, except after a day or so, the process starts throwing this error every time it tries to talk to my database.

Mysql::Error: Lost connection to MySQL server during query: SELECT * FROM incoming_email_messages WHERE (incoming_email_messages.name = 'UID26-1219353451') LIMIT 1

I have 4 rails instances running in a mongrel pack as well as 5 other daemon processes all talking to the same database. They never experience this loss of connectivity. The issue seems to be around my repeated calls to the Ruby pop3 library. I suspect that this is some kind of memory or garbage collection issue, but I don't know for sure. Right now, I have to bounce my thread once a day to snap it out of it. I tried moving the Net::POP3.new call outside the loop and just calling start/finish on the same object but that just make it stop working altogether.

Here is the thread

#!/usr/bin/env ruby