What is timing out, Spamsieve or my AppleScript?

I’m running an AppleScript to blocklist mail that I put in TrainTrash folder I created for iCloud. Once in a while there is a dialog that pops up that says “SpamSieve got an error: AppleEvent timed out. (-1712)”. This dialog hangs everything up because I have to respond to it. How to I either tell Spamsieve not to put up the dialog and just continue in some form, or increase Spamsieve’s timeout’s (which I done in my AppleScript). Based on adding debug statements to my AppleScript, it appears to be timing out somewhere in this area of my script,

set _source to my sourceFromMessage(_message)
tell application "SpamSieve"
set _score to score message _source without auto training

The debug log shows the following upon hang:

and the script and dialog looks like this:

Right this instance, there are only 10 messages in my Junk folder and I think less than that when the timeout occured.

Thanks

Rand

The program probably don’t need to run set score (if that is where the problem is because I’ve already put the name and address in the blocklist. Is this true? Commenting that out might solve the issue. I added another debug to determine which statement was timing out. I expect it is “set_score to score message…” but will know for sure eventually. Does it really take that long to do those two statements with less than 10 messages in the Junk mailbox?

Thanks

Rand

The timeout is in “set -score to score message…”. Never returns from that to log score.

image

Yes, you don’t want to use the score command if you are trying to train SpamSieve.

It shouldn’t. The score command is operating on one message at a time, so it wouldn’t depend on the number of messages. Normally it would take a fraction of a second per message. You could record a sample to see why that command is hanging.

In general, you can use with timeout to make AppleScript wait longer before timing out with an error, or you could catch the error with try and then exit the script to avoid reporting it with a modal dialog.

| Michael_Tsai Developer
June 21 |

  • | - |

Rand:

The program probably don’t need to run set score (if that is where the problem is because I’ve already put the name and address in the blocklist. Is this true?

Yes, you don’t want to use the score command if you are trying to train SpamSieve.

The issue was the score command timing out. I was using it to color the messages I was sending to trash but removed it because it kept timing out and just set score to 99.

Rand:

Does it really take that long to do those two statements with less than 10 messages in the Junk mailbox?

It shouldn’t. The score command is operating on one message at a time, so it wouldn’t depend on the number of messages. Normally it would take a fraction of a second per message. You could record a sample to see why that command is hanging.

In general, you can use with timeout to make AppleScript wait longer before timing out with an error, or you could catch the error with try and then exit the script to avoid reporting it with a modal dialog.

It was score timing out according to my logs. But I can do what I want to do without it or get the color from Mail and not re-score the message. Don’t really need color. It was just a way to see how SpamSieve trained the message after I trashed it if I wanted to review the trash quickly.

Thanks

Rand

You can just write something like:

set _message's background color to blue

to set the color.

Well I have to use score. When I TrainTrash and add name/source to blocklist, I have to go back and re-score the Junk folder to move the messages that were put there by iCloud mail that were not trained by SpamSieve. Just realized that. So I’ll trying increasing the timeout on the scoring statement.

Thanks

Rand

I think you are misunderstanding what score does. It doesn’t move any messages. It just asks SpamSieve to look at the message and decide whether it’s spam.

I also don’t understand why your script to process the TrainTrash mailbox is looking in the Junk mailbox.

I guess I have not explained what I’m trying to do.

  1. I have a mailbox in iCloud called “TrainTrash”
  2. When a piece of mail in my Junk mailbox appears that I never want to see again I move it to TrainTrash
  3. I have a script that looks at “TrainTrash” and puts the name and address in SpaimSieve’s blocklist
  4. Now that doesn’t work when iCloud junk filter put a message in Junk because SpamSieve never sees it
  5. So in my script I run through the Junk email folder re-scoring the messages so that SpamSieve will score the messages that are now in the blocklist as 99 so that I can move them to Trash.

I understand that score doesn’t move them to Trash. I do that in my script, but I need to know which ones that iCloud put in Junk that I trained as Trash so that they can be moved to Trash and this is the only way I have figured out how to do that. That is the reason to re-score the messages in Junk.

Does that help?

Thanks Michael

Rand

So you are using the Apple Mail - Rescue Good Messages script to have SpamSieve scan the Junk mailbox for messages caught by iCloud and move the blocklisted ones to the Trash?

But you want SpamSieve to look at some of these a second time after using TrainTrash to add blocklist rules for other messages from the same sender?

If so, I think your script should just set the message’s background color to none and then the regular SpamSieve script will reprocess the message instead of duplicating that functionality in your script.

Hey Michael,

I tried the with timeout on the set _score in my script. Still times out and I believe that my script isn’t timing out. I think SpamSieve is timing out on that set _score statement and displaying the dialog which happens before the with timeout in my script. Don’t know how to prevent that as I have no control over SpanSieve’s timeout or dialogs and there is no dialog displayed in my script. In fact the displayed Dialog says SpanSeive timed out.

Thanks

Rand

As I said, you can record a sample to see why SpamSieve is timing out or suppress the error to avoid the dialog. (It’s being shown by whatever is running your script, not SpamSieve.)

For example, you could write:

try
    set _score to score message _source without auto training
    -- Other stuff that depends on having the score
on error _error
    my debugLog("Error: " & _error)
end try

I will do that. Thanks

Rand