Error after upgradation to new sanic version

After upgrading to sanic==21.9.3 from sanic==21.3.4, Not a single api endpoint is working for me and all of them is giving me error on starting the. app.


[2021-12-02 17:17:30 +0530] [5901] [WARNING] You are using a deprecated error handler. The lookup method should accept two positional parameters: (exception, route_name: Optional[str]). Until you upgrade your ErrorHandler.lookup, Blueprint specific exceptions will not work properly. Beginning in v22.3, the legacy style lookup method will not work at all

and when making a call to any API, this error is popping up.

^[[B[2021-12-02 17:27:46 +0530] [5945] [ERROR] SPTK caught an error that should have been caught by Sanic response handler.
[2021-12-02 17:27:46 +0530] [5945] [ERROR] Could not find signal http.lifecycle.handle
[2021-12-02 17:27:46 +0530] [5945] [ERROR] Exception occurred while handling uri: 'http://localhost:8080/v1/api/users/ens_name_autocomplete'
Traceback (most recent call last):
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/signals.py", line 73, in get
    group, param_basket = self.find_route(
  File "", line 38, in find_route
sanic_routing.exceptions.NotFound: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/http.py", line 146, in http1
    await self.protocol.request_handler(self.request)
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic_plugin_toolkit/realm.py", line 550, in _handle_request_21_03
    _ = await real_handle(request)
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/app.py", line 769, in handle_request
    await self.dispatch(
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/signals.py", line 163, in dispatch
    return await dispatch
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/signals.py", line 114, in _dispatch
    raise e
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/signals.py", line 111, in _dispatch
    group, handlers, params = self.get(event, condition=condition)
  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic/signals.py", line 86, in get
    raise NotFound(message % tuple(terms))
sanic_routing.exceptions.NotFound: Could not find signal http.lifecycle.handle

How are you running the server?

I see you posted in GH: https://github.com/sanic-org/sanic/issues/2326

Closing that issue and I will respond here.

    app.run(host="0.0.0.0", port=8080, workers=workers, auto_reload=True, access_log=False,  reload_dir="./config")

I took your example and made it into a runnable script:

from sanic import Blueprint, Sanic, response

USERS_BP = Blueprint("users", url_prefix="/users", version=1)


@USERS_BP.post("signup")
async def signup(request):
    return response.json({})


app = Sanic("Testing")

APP_BP = Blueprint.group(USERS_BP, url_prefix="/api")
app.blueprint(APP_BP)


app.run(
    host="0.0.0.0",
    port=8080,
    workers=1,
    auto_reload=True,
    access_log=False,
    reload_dir="./config",
)
$ curl localhost:8080/v1/api/users/signup -X POST
{}

This is OK. There must be something else interfering. Are you by any chance trying to run multiple apps on different ports?

  File "/Users/sauravverma/Programs/ama.fans/py-server-backend/lib/python3.8/site-packages/sanic_plugin_toolkit/realm.py", line 550, in _handle_request_21_03

What plugins are you using? Maybe there is something that is not compatible?

Nopes, I am just running more than 1 worker.

Sanic-Cors==1.0.0
sanic-plugin-toolkit==1.0.1
sanic-routing==0.7.0
sanic-session==0.8.0

Looks like it is your Sanic CORS version. I replicated the issue with those version. Then ran

$ pip install --upgrade sanic-cors sanic-plugin-toolkit
...
Successfully installed sanic-cors-1.0.1 sanic-plugin-toolkit-1.2.0

Then it worked as expected.

I did this but then I started getting following error:
ERROR: Cannot install sanic==21.9.3, web3==5.25.0 and websockets==10.1 because these package versions have conflicting dependencies.

Which obviously is a web3 problem.

I’m not sure what that is and what it’s dependencies are.

But, you could try pip with the --legacy-resolver