Skip to content

Commit

Permalink
Merge pull request #172 from parente/403-not-402
Browse files Browse the repository at this point in the history
Switch 402 to 403 for kernel limit status
  • Loading branch information
jtyberg committed Jun 16, 2016
2 parents 28ccaf9 + d1654a2 commit 2a329b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kernel_gateway/services/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
}
}
},
"402": {
"403": {
"description": "The maximum number of kernels have been created.",
"schema": {
"$ref": "#/definitions/Error"
Expand Down
2 changes: 1 addition & 1 deletion kernel_gateway/services/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ paths:
description: Model for started kernel
type: string
format: url
402:
403:
description: The maximum number of kernels have been created.
schema:
$ref: '#/definitions/Error'
Expand Down
5 changes: 2 additions & 3 deletions kernel_gateway/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ def post(self):
Raises
------
tornado.web.HTTPError
402 Payment Required (for lack of a better HTTP error code and
mimicking what Google does) if the limit is reached
403 Forbidden if the limit is reached
"""
max_kernels = self.settings['kg_max_kernels']
if max_kernels is not None:
km = self.settings['kernel_manager']
kernels = km.list_kernels()
if len(kernels) >= max_kernels:
raise tornado.web.HTTPError(402, 'Resource Limit')
raise tornado.web.HTTPError(403, 'Resource Limit')

# Try to get env vars from the request body
model = self.get_json_body()
Expand Down
2 changes: 1 addition & 1 deletion kernel_gateway/tests/test_jupyter_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def test_max_kernels(self):
body='{}',
raise_error=False
)
self.assertEqual(response2.code, 402)
self.assertEqual(response2.code, 403)

# Shut down the kernel
kernel = json_decode(response.body)
Expand Down

0 comments on commit 2a329b4

Please sign in to comment.