Skip to main content

Process pool to add/check/stop all processes in pool

Project description

Install

pip3 install ccprocesspool --upgrade --user

Process Pool Usage

#!/usr/bin/env python3
# _*_ coding:utf-8 _*_
import time
from ccprocesspool import CCProcessPool


class CCProcessPoolTestJob(object):

    @staticmethod
    def count_instant_to_10():
        for i in range(0, 10):
            print('instant', i)

    @staticmethod
    def count_quick_to(param: int):
        for i in range(0, param):
            print('quick', i)

    @staticmethod
    def count_slow_to(param: int):
        for i in range(0, param):
            print('slow', i)
            time.sleep(1)


if __name__ == '__main__':
    p_m = CCProcessPool('test_pool')
    p_m.add_job(CCProcessPoolTestJob.count_instant_to_10, None)
    p_m.add_job(CCProcessPoolTestJob.count_quick_to, (10, ))
    p_m.add_job(CCProcessPoolTestJob.count_slow_to, (10, ))
    p_m.add_job(CCProcessPoolTestJob.count_slow_to, (10, ))
    p_m.check_job()
    while True:
        time.sleep(2)
        p_m.check_job()
        pass

Restartable Process Usage

p_m = CCRestartableProcess('test_process', CCRestartableProcessTestJob.count_slow_to_10)
p_m.start()
while True:
    time.sleep(5)
    p_m.restart()
    pass

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

ccprocesspool-2.1.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file ccprocesspool-2.1.tar.gz.

File metadata

  • Download URL: ccprocesspool-2.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for ccprocesspool-2.1.tar.gz
Algorithm Hash digest
SHA256 e720f2aaf922cc1070ee06deb9e3c43f3586d93bc82adc11537799f94ee0ea5e
MD5 edc5f9ac566adf3dd255d868b7684dc1
BLAKE2b-256 74084c1a68414534359ddec55dcf8e94b6646c31f59df970a3f180ce1df914b6

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