Fix pickling blueprints

Change the string passed in the "name" section of the namedtuples in Blueprint to match the name of the Blueprint module attribute name.
This allows blueprints to be pickled and unpickled, without errors, which is a requirment of running Sanic in multiprocessing mode in Windows.
Added a test for pickling and unpickling blueprints
Added a test for pickling and unpickling sanic itself
Added a test for enabling multiprocessing on an app with a blueprint (only useful to catch this bug if the tests are run on Windows).
This commit is contained in:
Ashley Sommer
2018-11-04 15:04:12 +10:00
parent 7d79a86d4d
commit 5cf2144b3f
2 changed files with 62 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ from sanic.views import CompositionView
FutureRoute = namedtuple(
"Route",
"FutureRoute",
[
"handler",
"uri",
@@ -17,11 +17,15 @@ FutureRoute = namedtuple(
"name",
],
)
FutureListener = namedtuple("Listener", ["handler", "uri", "methods", "host"])
FutureMiddleware = namedtuple("Route", ["middleware", "args", "kwargs"])
FutureException = namedtuple("Route", ["handler", "args", "kwargs"])
FutureListener = namedtuple(
"FutureListener", ["handler", "uri", "methods", "host"]
)
FutureMiddleware = namedtuple(
"FutureMiddleware", ["middleware", "args", "kwargs"]
)
FutureException = namedtuple("FutureException", ["handler", "args", "kwargs"])
FutureStatic = namedtuple(
"Route", ["uri", "file_or_directory", "args", "kwargs"]
"FutureStatic", ["uri", "file_or_directory", "args", "kwargs"]
)