https://github.com/devkral/channels-multiprocessing
https://github.com/devkral/channels-multiprocessing
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devkral/channels-multiprocessing
- Owner: devkral
- Created: 2022-12-30T23:22:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-27T12:40:20.000Z (over 2 years ago)
- Last Synced: 2025-03-09T12:18:50.528Z (8 months ago)
- Language: Python
- Size: 63.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```python
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_multiprocessing.MultiprocessingChannelLayer"
}
}
```
with explicit context
```python
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