Convenient multiprocessing with Message Queues
Features
- Lightning-fast startup: New processes launch in just 10ms.
- Lightning-fast execution: Sending code (with parameters) takes only 0.8ms.
- Easy to use: Thanks to
interactivity.py, minimal modifications are required. - Automatically suspends when idle, conserving resources.
Usage
(We recommend referring to example.py for guidance)
Creating Processes
import multiprocessing_mq as mq
my_pro = mq.Process(init=init_code, suspend=True, rest_time=0)
Parameters
init: Initialization code.suspend: Whether to suspend.rest_time: Sleep time.process_events: Performs event loop while waiting for process to resume, preventing UI from freezing.
Usage
There are multiple ways to send tasks to child processes. Among them, using inter is the simplest.
inter
Create a virtual class to simulate the environment of a child process. For example, to retrieve the value of a inside the child process, you only need my_pro.inter.a. Running a function only requires my_pro.inter.a().
run_com
Run a function and wait for a return value.
run_com(self, code: str, args: dict = {}, process_events=None)
code: The code to execute.args: Arguments (Note:argswon't automatically pass parameters; you need to pass them yourself withincode).process_events: Performs an event loop while waiting for the process result, preventing the UI from freezing.
Note: run_com uses eval to execute functions, so you cannot use it to modify variable values (you can use run_without_return instead).
run_without_return
run_without_return(self, code: str, args: dict = {})
Run a function without waiting for a return value; internally uses exec.
Metadata
Release files for multiprocessing-mq 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multiprocessing_mq-0.5.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multiprocessing_mq-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / multiprocessing_mq-0.5.tar.gz
| Download URL | multiprocessing_mq-0.5.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
979199232a38171efda7a1946e11813600723eb3ee4e393ab6b9e0b8ecdb9675
|
|
BLAKE2b-256 checksum How to use checksums |
c71e7b56309b04309b6f9602b9d3033e4bb7aaec6ac860747cc0a2f0ff9f2898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / multiprocessing_mq-0.5-py3-none-any.whl
| Download URL | multiprocessing_mq-0.5-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0977692e4f17020d9d1026026f2e472fdaa6b7d0542c1b906f01074cfc414f3
|
|
BLAKE2b-256 checksum How to use checksums |
428888708a91c41ad41274c5f2fce3ea744b823069d65be2905e4635278dac98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|