Skip to main content

Django channels with plain multiprocessing

Project description

Rational

Keep thinks simple and stupid.

Adding a redis service makes thinks more complicated

This is a try to use plain python utilities to provide channels layer functionality without configuration

idea

we leverage multiprocessing for providing a channel layer. As multiprocessing doesn't play always nice with async we use a per layer a Thread to serialize the internal requests. Per default the default mp_context is used for creating the manager for multiprocessing synchronization It may be set manually to "spawn" in case of an non python asgi server with multiple process workers

Usage

CHANNEL_LAYERS = {
"default": {
        "BACKEND": "channels_multiprocessing.MultiprocessingChannelLayer"
    }
}

with explicit context

CHANNEL_LAYERS = {
"default": {
        "BACKEND": "channels_multiprocessing.MultiprocessingChannelLayer",
        "CONFIG": {
            "mp_context": "spawn",
        },
    }
}

Note: all options of BaseLayer are supported (e.g. capacity)

State

tests passed

TODO

  • documentation
  • investigate aioprocessing

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

channels_multiprocessing-0.1.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

channels_multiprocessing-0.1.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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