Giter VIP home page Giter VIP logo

Comments (4)

JJTech0130 avatar JJTech0130 commented on September 16, 2024

you cannot do a manual closing because of the way trio is designed, all your code has to be in a with: block with the nursery to keep the background tasks alive and in-scope.
what you can do is use the less sugary API so that you can manage the trio nursery yourself, and put your whole script in a nursery.

from pypush.

JJTech0130 avatar JJTech0130 commented on September 16, 2024

probably the best way to make this clear is to just have your class have it's own async context manager, that way your users are aware that it needs to keep a connection open the whole time

it makes forgetting .close impossible, which means you can guarantee you do anything you need to do on shutdown
it makes it possible to use the nursery to schedule background notification handlers etc.

from pypush.

JJTech0130 avatar JJTech0130 commented on September 16, 2024

like what you would do is basically do what start's asynccontextmanager does, except you put the with APNSConnection.start block in there and inside that yield your own class instead of APNSConnection

from pypush.

novitae avatar novitae commented on September 16, 2024

The workaround I did is save push creds into the class attributes, and then open a connection with them each time I need it inside a class's method. Should do the job for now !

from pypush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.