Skip to main content

A worker dispatcher with multiprocessing and multithreading.

Project description

Module burncpu is a worker dispatcher with multiprocessing and multithreading.

Features

  • All CPU cores can be used.

  • Workers can be stopped gracefully by system signals.

  • Pure python code.

Quickstart

Use the following command to run the sample module.

python3 -m burncpu.sample

Then monitor CPU status, some changes take place at these time.

Time

Events

0s

All CPU cores are IDLE.

10s

Workers begin to call one_second_task many times.

60s

Workers begin to terminate.

Pressing Ctrl+C or sending system signal can also terminate the sample.

Finally copy and modify the source code to make your own.

Reference

To import

from burncpu.dispatcher import WorkerDispatcher

class WorkerDispatcher

WorkerDispatcher.__init__(worker_count=0, use_core=0, time_limit=0)

Create a dispatcher instace.

worker_count

How many threads would be created, 0 means create ([use_core] * 2) threads.

use_core

How many cores would be use, 0 means all cores.

time_limit

Stop workers after [time_limit] seconds.

WorkerDispatcher.dispatch(func, args)

Dispatch a function to one of workers randomly.

func

Function to call.

args

Argument list of this function.

WorkerDispatcher.sleep(seconds)

Sleep dispatcher for given seconds.

seconds

Seconds to sleep. Dispatcher would not sleep given seconds actually. It sleep many times during given seconds, so that system signal (e.g. Ctrl+C) can be handled.

WorkerDispatcher.join()

Wait until all workers stopped.

WorkerDispatcher.is_alive()

Check if the dispatcher is alive.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

burncpu-0.0.15-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file burncpu-0.0.15-py3-none-any.whl.

File metadata

File hashes

Hashes for burncpu-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 7cb0ce291d877cc1284a980a32c0acf94e06b3e077c3877689da5bd7aaa53bfa
MD5 6b2383f6c0a56a46ccb01c434b8659e0
BLAKE2b-256 587112d9c07dd770c47c43fcca45de93bef494a31bae18c709dd73cd6a4cf70f

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