I want to set TimeConstrained globally, I tried use $PrePrint as bellowed script:

$PrePrint = TimeConstrained[#,5] &;

But there's no effect, evaluation could not be aborted within given time.

So is there any way to do this? Thanks!

  • 2
    $\begingroup$ Consider $Pre and related items. $\endgroup$
    – bbgodfrey
    Commented Aug 31, 2015 at 4:00
  • $\begingroup$ @bbgodfrey Thanks a lot. I found the solution by searching '$Pre'. $\endgroup$
    – Michael
    Commented Aug 31, 2015 at 5:39

1 Answer 1


I found the solution in another topic here

How to stop the Kernel from running wild?

SetAttributes[timecon, HoldAll]
timecon[new_] := TimeConstrained[new, 5]
$Pre = timecon;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.