There's an example of this in Molly's sakai code here:
https://github.com/mollyproject/mollyproject/blob/master/molly/apps/sakai/views.py#L38-L51

Here we set a context manager and reset the defaulttimeout afterwards. That way you don't create a side-effect in other code.