Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with sanic>21.6 #61

Open
rmk135 opened this issue Oct 28, 2021 · 7 comments
Open

Problem with sanic>21.6 #61

rmk135 opened this issue Oct 28, 2021 · 7 comments

Comments

@rmk135
Copy link

rmk135 commented Oct 28, 2021

Hey,

Thanks for the great library!

Seems like there is an error on sanic > 21.6. The failure I see looks like that:

ERROR    sanic.error:http_protocol.py:110 protocol.connection_task uncaught
Traceback (most recent call last):
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/server/protocols/http_protocol.py", line 101, in connection_task
    await self.app.dispatch(
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 163, in dispatch
    return await dispatch
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 111, in _dispatch
    group, handlers, params = self.get(event, condition=condition)
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 73, in get
    group, param_basket = self.find_route(
TypeError: 'NoneType' object is not callable
ERROR    asyncio:plugin.py:76 Task exception was never retrieved
future: <Task finished name='Task-19' coro=<HttpProtocol.connection_task() done, defined at /Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/server/protocols/http_protocol.py:92> exception=TypeError("'NoneType' object is not callable")>
Traceback (most recent call last):
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/server/protocols/http_protocol.py", line 130, in connection_task
    await self.app.dispatch(
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 163, in dispatch
    return await dispatch
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 111, in _dispatch
    group, handlers, params = self.get(event, condition=condition)
  File "/Users/rmk/projects/ets-labs/python-dependency-injector/venv/lib/python3.10/site-packages/sanic/signals.py", line 73, in get
    group, param_basket = self.find_route(
TypeError: 'NoneType' object is not callable

The failure occurs all the time, but if you need an example, take a look at: https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/sanic

Thanks,
Roman

@wochinge
Copy link

wochinge commented Nov 5, 2021

We have the same problem 😬

@wochinge
Copy link

wochinge commented Nov 5, 2021

Created a fix here but would need some feedback

@autumnjolitz
Copy link

Created a fix here but would need some feedback

The events system was overhauled in sanic-org/sanic#2160

So you'll need to also add

        await self.app._server_event("init", "before")
        # Trigger after_start events
        await self.app._server_event("init", "after")

after await self.app._startup()

@notzippy
Copy link

notzippy commented May 16, 2022

This is a showstopper for me. This package is unusable without a fix for sanic 21 (working addition to changes)

    await self.app._startup()
    await self.app._server_event("init", "before", loop=self.loop)
    # Trigger after_start events
    await self.app._server_event("init", "after", loop=self.loop)

@indam23
Copy link

indam23 commented Jul 1, 2022

I've ported the fix from @wochinge to here #66 and added the changes you mentioned @autumnjolitz

@autumnjolitz
Copy link

Hi @melindaloubser1 , I managed to rederive the same fixes you made lol

Wasn't paying attention till Google's auth libraries made me upgrade and jesus christ wow the internal fiddling is awful

@evialevy
Copy link

Im having this issue with signals -> find_route func is None, when running a test REST call using pytest-sanic 19, sanic-testing
Sanic version is 22.6.1
If Im trying to run with simply app.asgin_client.get(...) find_route is not None but im failing on
sanic.exceptions.SanicException: Loop can only be retrieved after the app has started running. Not supported with create_server function

Can someone suggest a solution - im very blocked with Sanic version upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants