Skip to main content

Posix IPC-backed ASGI channel layer implementation

Project description

https://api.travis-ci.org/django/asgi_ipc.svg https://img.shields.io/pypi/v/asgi_ipc.svg

An ASGI channel layer that uses POSIX shared memory IPC as its backing store (only works between processes on the same machine).

IPC is still a bit of a wild west of UNIX compatability, so if you find weird errors, please file an issue with details and exact system specifications. In partcular, this module is tested and works well on Linux kernels and the Windows Subsystem for Linux; it also works on Mac OS but will not be able to detect deadlock situations due to limitations in the kernel.

Usage

You’ll need to instantiate the channel layer with a path prefix to create IPC objects underneath; any channel layers with the same prefix will talk to each other as long as they’re on the same machine.

Example:

import asgi_ipc as asgi

channel_layer = asgi.IPCChannelLayer(
    prefix="aeracode",
    message_memory=200 * 1024 * 1024,
)

channel_layer.send("my_channel", {"text": "Hello ASGI"})
print(channel_layer.receive(["my_channel", ]))

prefix

Prefix to use for IPC objects under the root namespace. Defaults to asgi. IPC layers on the same machine with the same prefix will talk to each other.

message_memory

The amount of shared memory to allocate to the channel storage, in bytes. Defaults to 100MB. All of your in-flight messages must fit into this, otherwise you’ll get ChannelFull errors if the memory space is full up.

ASGI messages can be a maximum of one megabyte, and are usually much smaller. The IPC routing metadata on top of each message is approximately 50 bytes.

group_memory

The amount of shared memory to allocate to the group storage, in bytes. Defaults to 20MB. All of your group membership data must fit into this space, otherwise your group memberships may fail to persist.

You can fit approximately 4000 group-channel membership associations into one megabyte of memory.

expiry

Message expiry in seconds. Defaults to 60. You generally shouldn’t need to change this, but you may want to turn it down if you have peaky traffic you wish to drop, or up if you have peaky traffic you want to backlog until you get to it.

group_expiry

Group expiry in seconds. Defaults to 86400. Interface servers will drop connections after this amount of time; it’s recommended you reduce it for a healthier system that encourages disconnections.

capacity

Default channel capacity. Defaults to 100. Once a channel is at capacity, it will refuse more messages. How this affects different parts of the system varies; a HTTP server will refuse connections, for example, while Django sending a response will just wait until there’s space.

channel_capacity

Per-channel capacity configuration. This lets you tweak the channel capacity based on the channel name, and supports both globbing and regular expressions.

It should be a dict mapping channel name pattern to desired capacity; if the dict key is a string, it’s intepreted as a glob, while if it’s a compiled re object, it’s treated as a regular expression.

This example sets http.request to 200, all http.response! channels to 10, and all websocket.send! channels to 20:

channel_capacity={
    "http.request": 200,
    "http.response!*": 10,
    re.compile(r"^websocket.send\!.+"): 20,
}

If you want to enforce a matching order, use an OrderedDict as the argument; channels will then be matched in the order the dict provides them.

Dependencies

All Channels projects currently support Python 2.7, 3.4 and 3.5.

Contributing

Please refer to the main Channels contributing docs. That also contains advice on how to set up the development environment and run the tests.

Maintenance and Security

To report security issues, please contact security@djangoproject.com. For GPG signatures and more security process information, see https://docs.djangoproject.com/en/dev/internals/security/.

To report bugs or request new features, please open a new GitHub issue.

This repository is part of the Channels project. For the shepherd and maintenance team, please see the main Channels readme.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asgi_ipc-1.4.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

asgi_ipc-1.4.0-py2.py3-none-any.whl (9.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file asgi_ipc-1.4.0.tar.gz.

File metadata

  • Download URL: asgi_ipc-1.4.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asgi_ipc-1.4.0.tar.gz
Algorithm Hash digest
SHA256 1bae453d771eb92c0ec558b826fc0bce75a2a61bf21187784d4e4dc11710e588
MD5 bdefbc5eaa661d775116868555c74033
BLAKE2b-256 57f7c5087b1d723f3ddc2369ac549563dca9d4fce2d7147ffbcea04777216780

See more details on using hashes here.

File details

Details for the file asgi_ipc-1.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for asgi_ipc-1.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cfebd451c047f5ea2da998679fd0fc02ff3cd648b02db624ce33b5983dc3eaa4
MD5 90e91d1a16402f7a9b01f56d27af57b5
BLAKE2b-256 870a1a84571969f052967a3fb9efa7e7fe345944834feab0003883d260140bae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page