M
marathoner
Hi,
I have a programs that checks emails via IMAP and then sleeps for 30
seconds. Occasionally, it hangs on the line where it calls sleep(30).
I use Perl 5.8.8 (ActivePerl Build 820) running on Windows 2000 SP4.
A simplified version of the code looks like this:
use Mail::IMAPClient;
$host = 'localhost';
$id = 'user';
$pass = 'pass';
$inbox = 'inbox';
while(1)
{
print scalar localtime, "\n";
$imap = Mail::IMAPClient->new(
Server => $host,
User => $id,
Password=> $pass,
Clear => 5,
Debug => 0,
Timeout => 30,
Uid => 0,
) or die "Cannot connect to $host as $id: $@";
print "Checking for new messages...\n";
$imap->select($inbox);
$m = $imap->message_count();
for $n (1..$m)
{
print $imap->get_header($n, 'To');
# more processing here
# .......
$imap->delete_message($n);
}
$imap->expunge();
$imap->disconnect();
print scalar localtime, "\n";
print "Done. See you in 30 seconds.\n\n\n";
sleep(30); # <-- this is where it hangs sometimes
print "waking up...\n\n";
}
Any input would be much appreciated.
Thank you.
Lei
I have a programs that checks emails via IMAP and then sleeps for 30
seconds. Occasionally, it hangs on the line where it calls sleep(30).
I use Perl 5.8.8 (ActivePerl Build 820) running on Windows 2000 SP4.
A simplified version of the code looks like this:
use Mail::IMAPClient;
$host = 'localhost';
$id = 'user';
$pass = 'pass';
$inbox = 'inbox';
while(1)
{
print scalar localtime, "\n";
$imap = Mail::IMAPClient->new(
Server => $host,
User => $id,
Password=> $pass,
Clear => 5,
Debug => 0,
Timeout => 30,
Uid => 0,
) or die "Cannot connect to $host as $id: $@";
print "Checking for new messages...\n";
$imap->select($inbox);
$m = $imap->message_count();
for $n (1..$m)
{
print $imap->get_header($n, 'To');
# more processing here
# .......
$imap->delete_message($n);
}
$imap->expunge();
$imap->disconnect();
print scalar localtime, "\n";
print "Done. See you in 30 seconds.\n\n\n";
sleep(30); # <-- this is where it hangs sometimes
print "waking up...\n\n";
}
Any input would be much appreciated.
Thank you.
Lei