ASGI implemented as a Twisted resource
Project description
txasgiresource is ASGI implemented as a Twisted Web Resource, very similar to WSGIResource.
This is inspired by Daphne but largely implemented from specs.
It can also run as a daemon with or without the actual application embedded inside.
The code is available on GitHub
Usage
As Twisted Resource
from twisted.web import server
from yourdjangoproject.asgi import channel_layer
resource = ASGIResource(channel_layer)
site = server.Site(resource)
# If we are done with the resource, make sure to stop it.
resource.stop()
As ASGI Protocol server
twistd -n txasgi -c yourdjangoproject.asgi:channel_layer
As ASGI Protocol server with embedded workers
twistd -n txasgi -c yourdjangoproject.asgi:channel_layer -w 6
As ASGI Protocol server with embedded workers and on a different port and ip
twistd -n txasgi -c yourdjangoproject.asgi:channel_layer -w 6 -d tcp:5566:interface=0.0.0.0
Scheduler
The scheduler is built around apscheduler and directly maps to the three schedule-types:
Schedule a job
Channel('schedule').send({
'method': 'add',
'id': 'some_unique_job_id',
'reply_channel': 'schedule.time_to_run',
'reply_args': {'some', 'reply'},
'trigger': 'date',
'run_date': '2009-11-06 16:30:05',
})
Setup channel for the reply
channel_routing = {
'schedule.time_to_run': 'myapp.consumers.my_consumer',
}
Cancel the job
Channel('schedule').send({
'method': 'remove',
'id': 'some_unique_job_id',
})
Status
Master branch
Develop branch
License
MIT, see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
txasgiresource-0.4.0.tar.gz
(14.0 kB
view hashes)
Built Distribution
Close
Hashes for txasgiresource-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3421e6d3691ed17595d503b38343bada44b244c1d0ed64e2cd2c788b2077a5a |
|
MD5 | fa555e250574c8871a36b84544d583ae |
|
BLAKE2b-256 | 0a0ecf9530a5376923bd7b7ea24c19788aa8d63ded3cad317cc8b61e2c8c6bef |