Skip to main content

run tasks in parallel

Project description

run tasks in parallel,it can replace for loop to this way,easy and faster

from task_multiprocess.main import generate_queue,cpu_num,common_multiprocess

cpu_num = 3 sample_list = list(range(100))[:] # [int,int,...] or [str,str,...] or ... q, q_size, lock, public_list = generate_queue(sample_list,num=2) # num means how many public_list do you want,you can use index to use them like public_list[0] or others

def add(ids): index = ids[0]
index = int(index) fun(index) # fun is an function defined by yourself

common_multiprocess(add,1,cpu_num=cpu_num,q=q, q_size=q_size, lock=lock)


new version

from task_multiprocess.main import TaskMultiprocess TaskMultiprocess.cpu_num = 2 tm = TaskMultiprocess() sample_list = list(range(1000))[:] # [int,int,...] or [str,str,...] or ... q, q_size, lock, public_list = tm.generate_queue(sample_list,num=2) # num means how many public_list do you want,you can use index to use them like public_list[0] or others

def add(ids): index = ids[0]
index = int(index) fun(index) # fun is an function defined by yourself

tm.common_multiprocess(add,q_num=1,q=q, cpu_num=tm.cpu_num,q_size=q_size, lock=lock)

add is a function defined by yourself \

q_num means how many variable do you want to get each time
in this example only use index 0 to get one variable -> (index = ids[0]), you can also get 2,3 or more (a, b = ids[0],ids[1]), remember to replace 1 to the number you want

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

task_multiprocess-0.0.6.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

task_multiprocess-0.0.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file task_multiprocess-0.0.6.tar.gz.

File metadata

  • Download URL: task_multiprocess-0.0.6.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for task_multiprocess-0.0.6.tar.gz
Algorithm Hash digest
SHA256 05f0f1a17ef5360fff346fa5e3fb1569c72f1c52400826a7ae9bebb00e3e85fa
MD5 a7f72f13b8a313f1a0dc8f44cab4395f
BLAKE2b-256 7b5ade186afdb53736bf81882223f39f706af680f25bd5f1aa8e0f9d3a0d48dc

See more details on using hashes here.

File details

Details for the file task_multiprocess-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for task_multiprocess-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 66dcd6652b35968711419f2ae13d90383bc058c98455fff9268f480ee34087a3
MD5 95d3f91dc19f79909a076528f0acfcf6
BLAKE2b-256 749488bc949610919a2e025c1ace297aad82031e68db43b94ba69f13c012ce3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page