Prior to this change, the request timeout for a Gateway request
was synchronized with KERNEL_LAUNCH_TIMEOUT only if KLT
was greater. However, the two are closely associated and KLT
should be adjusted if the configurable request_timeout is greater.
This change ensures that the two values are synchronized to the
greater value. It changes the two configurable timeouts to default
to 40 (to match that of KLT) and removes the 2-second pad,
since that wasn't helpful and only confused the situation.
These changes were prompted by this issue: jupyter/enterprise_gateway#792
`gateway_request` in `gateway.manager` raises `tornado.web.HTTPError` exceptions,
but the callers, such as `GatewayKernelManager.get_kernel`, catch
`tornado.httpclient.HTTPError`, instead of `tornado.web.HTTPError`.
Therefore, the callers can not handle exceptions during gateway interactions.
This causes that, for example, when Jupyter Enterprise Gateway culled a kernel
by idle timeout, the gateway manager can not handle the kernel's absent appropriately.
As a result, notebook users see ambiguous "Kernel Error" and can not restart
the kernel or start a new kernel.
When the NotebookApp raises an exception on initialization, a test can
hang forever. This can happen when passing configuration when
customizing NotebookTestBase:
```
class TestMissingExtension(NotebookTestBase):
@classmethod
def get_argv(cls):
argv = super(TestMissingExtension, cls).get_argv()
argv.extend(
[
"--NotebookApp.session_manager_class=doesnt_exist",
]
)
return argv
def test_this_will_hang_forever(self):
pass
```
Since the exception happens before the try/finally the `Event` will
never be triggered. By including the construction and initialization of
the notebook in the try/finally we can handle situations like this.
Moved 'assert mode == keyboard_mode' ouside the branches.
This means that if a unknown mode comes its gonna get catched by the
assert and never gona get to the else statement.
For this, the else stament moved to before the assert, caching the mode
error before the assert.
Previously know as validate_notebook_mode changed name to
validate_dualmode_mode to represent better the method.
Added a docstring.
Removed the handling of index being None.