by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Roan
    @rsakeys
    has anyone else got this error before? https://pastebin.com/ZYKvQ37z
    Ashley Sommer
    @ashleysommer
    @rsakeys Are you using Sanic version 20.3.0? It was released literally today. A lot of plugins won't have compatibility. That error you are seeing is because the sanic-session plugin hasn't been updated to work with Sanic v20.3.0
    To be more specific... in Sanic 19.9 the sanic.Request object class gained the ability to add arbitrary attributes to the request class. This is how sanic-session stores your session against your incoming request. This was deprecated in Sanic v19.12 in favor of usign the request.ctx context object. In v20.3.0 the deprecated feature was removed. Looks like sanic-session hasn't caught up yet.
    vspolireddy
    @vspolireddy
    Screen Shot 2020-05-15 at 4.33.55 PM.png

    Hi All very simple question I might be thinking too much into, thanks in advance for taking a look

    I am trying to access this cassandra client outside of these defined listeners below that get registered to a sanic main app.

    I need the session in order to use an update query which will execute Asynchronously. I can definetly connect and event query from the 'setup_cassandra_session_listener' method below. But having tough time figuring how to call this Cassandra session outside and isolate so i can access else where.

    Ashley Sommer
    @ashleysommer
    @vspolireddy Sanic-Plugins-Framework can do this. Its a bit involved, you'd need to write your own Sanic-Cassandra plugin using SPF but it will allow you to register the session on startup, store the session in the plugin's own private persistent context, and use that session elsewhere in the application when required.
    vspolireddy
    @vspolireddy

    @ashleysommer not required at all solved thank you for taking a look! :)

    https://stackoverflow.com/questions/61827879/trying-to-access-an-object-from-a-listener-python-web-framework

    Justin
    @Paladiamors
    @ashleysommer Thanks for posting on the sanic-session git repo recently. The maintainer has just pushed out the release with the submitted fix an hour ago. Would it be in the cards of the sanic organization to have an integration test dashboard to let users know what plugins are working ok on the latest version? It would be helpful to highlight to the community the compatibility status and let people know what might need some work when putting out breaking changes.
    Adam Hopkins
    @ahopkins
    How would you envision that working? How could we (as an organization) manage that?
    I'm open to the thought since I'm working on a new frontpage for sanicframework.org
    This seems more like something for package maintainers, no?
    Primarily, how do you decide what plug-ins to display?
    Do you know of any other frameworks with something like this?
    Justin
    @Paladiamors

    The Python 2 -> 3 migration had a dashboard like that and developers had in the past chose the flavor of Python they would use based on the availability of the packages they needed.

    One of the reasons I got into sanic recently is indeed for the speed and the simplicity of the code. Sanic is indeed growing and I think having a way of showing what key modules are used and its stability would also be encouraging to enterprises that might be interested in using this stack. If enterprises start using it, I think the popularity of sanic could also grow.

    In terms of picking which plugins to display, I think that would be up to you as the maintainers or even have a separate team that would accept modules that are for sanic. Django has something like django packages: https://djangopackages.org/
    Adam Hopkins
    @ahopkins
    Ah true. I forgot about Django packages.
    Justin
    @Paladiamors
    Would there be a schedule to have an update to the 20.3.0 release logs by any chance? I'm not able to find the details just yet here: https://github.com/huge-success/sanic/blob/master/CHANGELOG.rst
    Adam Hopkins
    @ahopkins
    Yes. I apologize that it did not accompany the release. We have been thrown for a loop with this last release and are recollecting to do better for 20.6
    Justin
    @Paladiamors
    Not a problem, much appreciated for all the hard work that you guys are doing.
    Anh Mai
    @theanht1
    Hey guys, I have a question on Sanic app context
    Basically I'm working on a project that supports running on both Sanic and CLI, and I want to know whether a function is called on app context or not. It's kind of has_app_context in Flask,
    but I didn't find something similar in Sanic
    Thanks for taking a look
    Adam Hopkins
    @ahopkins
    Even though Sanic's routing and handler mechanism looks like Flask, Sanic does not try to achieve a parity of API design. I apologize, but I am not familiar with has_app_context. In what case do you use it?
    If your function called is the same as your handler, then you can access your app from request.app
    Marwan Rabbâa
    @waghanza
    /@all I have compare sanic and other python frameworks
    https://github.com/the-benchmarker/web-frameworks/tree/cloudify#results :tada:
    Ewan Higgs
    @ehiggs
    Neat; the backend for covid contact tracing in italy is using sanic: https://github.com/immuni-app/immuni-backend-common
    @waghanza did you test this on a mac laptop in docker? Or did you test this on actual infra?
    2 replies
    Adam Hopkins
    @ahopkins
    Results are run on Digital Ocean.
    3 replies
    I see now 🤦‍♂️ my bad
    Marwan Rabbâa
    @waghanza
    :-)
    Ahmed
    @ahmedhr

    debug sanic with pycharm when debug=False
    , if we want to keep debug=True we also have to explicitly mention auto_reload=False

    Microsoft/vscode-python#2316

    Is this a bug?

    Adam Hopkins
    @ahopkins
    nope
    that is intentional
    debug mode automatically enables auto reload on purpose
    if you only want the debug logging, and not reload, then you need to be explicit.
    Ahmed
    @ahmedhr
    Alright, makes sense. Thanks!
    Andrew Bastien
    @volundmush
    Sanic peoples! I am curious
    So I am looking at the 'Custom Protocols' thing and am wondering about just how far those can go. For instance, what about protocols that don't necessarily generate a response - such as Telnet? I am currently working on something MUD-related and want to use modern Python to give it web features so am looking at various ASGI technologies built on Asyncio for this purpose....
    it seems like every single ASGI-related tool and library assumes HTTP+WebSockets. which, I mean, that's a fairly sensible assumption to make I suppose, but...
    I'm imagining a server that opens up several ports, each serving different protocols - one is telnet, another is ssh, then a third is HTTP+WS...
    Adam Hopkins
    @ahopkins
    First, Sanic is not an ASGI server. You would need to use uvicorn, hypercorn, or daphne if you wanted ASGI. With that said, I am not familiar enough with the internals of any of those tools of they can be configured to handle any service other than http and websockets.
    Sanic is an ASGI framework. But, as such, it would exist only in the http and websockets world.
    Second, Sanic does ship with its own web server
    This is not based upon the ASGI event system.
    It is based directly upon asyncio.Protocol
    While I have never done either of those, if definitely should be possible
    Andrew Bastien
    @volundmush
    yeah I am starting to understand more about how this works after reading a bit more. ASGI was confusing me a bit but I see the difference between server and app now
    Adam Hopkins
    @ahopkins
    :+1: I am really interested to hear how this comes out. If you do come up with something, would you mind sharing in the community forums?
    I guess the main distinction worth pointing out is that Sanic is first and foremost a server and web framework.
    It also just so happens to allow for the "framework" to also be hooked into an ASGI server if you need
    rlundy82
    @rlundy82
    I'm new to async development. I'm coming from a Flask(ish) background, so I'm loving the way Sanic looks to me. I've got a question regarding Sanic-WTF.