aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--snekbox/api/resources/eval.py4
-rw-r--r--snekbox/api/snekapi.py9
3 files changed, 13 insertions, 5 deletions
diff --git a/README.md b/README.md
index 2e2ee9c..533481e 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,9 @@ NsJail is configured through [`snekbox.cfg`]. It contains the exact values for t
### Gunicorn
-[Gunicorn settings] can be found in [`gunicorn.conf.py`]. In the default configuration, the worker count and the bind address are likely the only things of any interest. Since it uses the default synchronous workers, the [worker count] effectively determines how many concurrent code evaluations can be performed.
+[Gunicorn settings] can be found in [`gunicorn.conf.py`]. In the default configuration, the worker count, the bind address, and the WSGI app URI are likely the only things of any interest. Since it uses the default synchronous workers, the [worker count] effectively determines how many concurrent code evaluations can be performed.
+
+`wsgi_app` can be given arguments which are forwarded to the `NsJail` object. For example, `wsgi_app = "snekbox:SnekAPI(max_output_size=2_000_000, read_chunk_size=20_000)"`.
### Environment Variables
@@ -125,3 +127,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
[sentry release]: https://docs.sentry.io/platforms/python/configuration/releases/
[data source name]: https://docs.sentry.io/product/sentry-basics/dsn-explainer/
[GitHub Container Registry]: https://github.com/orgs/python-discord/packages/container/package/snekbox
+[`NsJail`]: snekbox/nsjail.py
diff --git a/snekbox/api/resources/eval.py b/snekbox/api/resources/eval.py
index 7c23a52..1df6c1b 100644
--- a/snekbox/api/resources/eval.py
+++ b/snekbox/api/resources/eval.py
@@ -29,8 +29,8 @@ class EvalResource:
"required": ["input"],
}
- def __init__(self):
- self.nsjail = NsJail()
+ def __init__(self, nsjail: NsJail):
+ self.nsjail = nsjail
@validate(REQ_SCHEMA)
def on_post(self, req: falcon.Request, resp: falcon.Response) -> None:
diff --git a/snekbox/api/snekapi.py b/snekbox/api/snekapi.py
index a1804e6..5a8d390 100644
--- a/snekbox/api/snekapi.py
+++ b/snekbox/api/snekapi.py
@@ -1,5 +1,7 @@
import falcon
+from snekbox.nsjail import NsJail
+
from .resources import EvalResource
@@ -7,6 +9,8 @@ class SnekAPI(falcon.App):
"""
The main entry point to the snekbox JSON API.
+ Forward arguments to a new `NsJail` object.
+
Routes:
- /eval
@@ -21,6 +25,7 @@ class SnekAPI(falcon.App):
"""
def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
+ super().__init__()
- self.add_route("/eval", EvalResource())
+ nsjail = NsJail(*args, **kwargs)
+ self.add_route("/eval", EvalResource(nsjail))