Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint 2010 Sandbox Solution Timeout

Is there a way to adjust the timeout value for a SharePoint 2010 sandbox solution? I think it defaults to 30 seconds. I have a web part that occasionally runs a little longer than that. I really would prefer not to fall back to a farm solution if I can avoid it.

like image 898
Scott Price Avatar asked Jan 19 '23 23:01

Scott Price


1 Answers

Finding the documentation on this was a little difficult, but I found it here. The relevant parts are these:

Per Request, with the Request Penalized: There is a hard limit to how long a sandboxed solution can take to be completed. By default, this is 30 seconds. If a sandboxed solution exceeds the limit, the application domain that handles the request (but not the sandboxed worker process) is terminated. This limit is configurable, but only through custom code against the object model. The relevant parts of the object model cannot be accessed by sandboxed solutions, so no sandboxed solution can change the limit.

CPU Execution Time The absolute limit of this resource is not applicable as long as it is set higher than the Per Request, with the Request Penalized limit described above. Normally, administrators will want to keep it higher so that the slow request is terminated before it causes a termination of the whole sandboxed worker process, including even the well-behaved sandboxed solutions running in it.

The following code can be used to adjust Per Request timeout:

SPUserCodeService.Local.WorkerProcessExecutionTimeout = 40;
SPUserCodeService.Local.Update();

You should be able to adjust the CPU Execution Time with something like the following:

SPUserCodeService.Local.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit = 50.0;
SPUserCodeService.Local.Update();

You have to restart the Microsoft SharePoint Foundation Sandboxed Code Service for the changes to take effect.

like image 180
Scott Price Avatar answered Jan 31 '23 13:01

Scott Price