# Do palettes limit the execution time of a user-defined function?

I have defined a function ConvertToMarkdown that does some long processing of a notebook: converts it to markdown, save inputs/outputs as images, generates a word cloud etc., that can take multiple seconds to run - for example, for a particular notebook the execution time is 17s.

This function runs fine when called from a notebook, but when I put it on a button in a palette, it only generates partial output (e.g., word cloud is not generated, and some other files). It was running fine from the palette before I've added the word cloud generation, as this is an expensive operation.

Looking at trace for (other, unrelated) messages from the same function, it looks like the palette function is run inside TimeConstrained, which makes sense, as you want your front end to be responsive. The time limit is apparently 6 seconds,

which is numerically the same value as Cell Options->Evaluation Options->DynamicEvaluationTimeout for my notebook, and even though I couldn't find an explicit confirmation in the documentation, I assume that's the parameter that controls the time limit.

My question is: what's the best way to temporarily increase this limit? I assume one option would be SetOptions[\$FrontEndSession, DynamicEvalutionTimeout -> 20] temporarily within the palette, and then reset it back to the original value; is this how I should do it?

• You need to add Method -> "Queued" to the Button that starts the process. – Kuba Apr 20 '20 at 9:12
• Perfect, thanks @Kuba! Just checked it, and it works. If you could please type this as an answer, I will accept it. – Victor K. Apr 20 '20 at 9:16
• I will try to find a duplicate first, sound like it was already asked. I am glad I helped. p.s. MD related: 84556 – Kuba Apr 20 '20 at 10:38
• Thanks for MD link, I will study it. But as they say, everyone likes to write their own blogging engine, and as I use Jekyll already, MD conversion is all that is left. Plus, I have a couple of specific requirements (e.g., adding some CSS to various elements etc.) that are specific for my use case. – Victor K. Apr 20 '20 at 15:12