Giter Club home page Giter Club logo

txasgiresource's Introduction

txasgiresource

txasgiresource is ASGI implemented as a Twisted Web Resource, very similar to WSGIResource.

This is inspired by Daphne but somewhat implemented from specs.

It can also run as a daemon.

The code is available on GitHub

Usage

As Twisted Resource

from twisted.web import server

from yourdjangoproject.routing import application

resource = ASGIResource(application)
site = server.Site(resource)

# If we are done with the resource, make sure to stop it.

yield resource.stop()

As ASGI Protocol server

twistd -n txasgi -a yourdjangoproject.routing:application

As ASGI Protocol server on a different port and ip

twistd -n txasgi -a yourdjangoproject.asgi:channel_layer -d tcp:5566:interface=0.0.0.0

Supported specifications

Specification Supported
asgi2 Yes, through compatibility handler
asgi3 Yes
HTTP Yes, v2.0
Websocket Yes, v2.0
Lifespan No

Status

Master branch

https://coveralls.io/repos/github/JohnDoee/txasgiresource/badge.svg?branch=master https://travis-ci.org/JohnDoee/txasgiresource.svg?branch=master

Develop branch

https://coveralls.io/repos/github/JohnDoee/txasgiresource/badge.svg?branch=develop https://travis-ci.org/JohnDoee/txasgiresource.svg?branch=develop

License

MIT, see LICENSE

txasgiresource's People

Stargazers

Carlton Gibson avatar  avatar Jordan Eremieff avatar  avatar Harshad Sharma avatar  avatar Nikolaus Schlemm avatar Tom Christie avatar Krukov D avatar Jakub Skałecki avatar Anders Jensen avatar

Watchers

Anders Jensen avatar James Cloos avatar

txasgiresource's Issues

Handle asyncio.CancelledError

Running a REST-based asgi application I get the following error logs at the end of every request:
Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/home/appuser/.local/lib/python3.9/site-packages/txasgiresource/application.py", line 43, in handle_cancel_exception f.exception() asyncio.exceptions.CancelledError

Asyncio tasks throw asyncio.CancelledError, not concurrent.futures.CancelledError; I believe ApplicationManager.finish_protocol.handle_cancel_exception should be updated to catch this exception as well.

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.