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) # add is a function defined by yourself
params 1 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.5.tar.gz (3.3 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.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: task_multiprocess-0.0.5.tar.gz
  • Upload date:
  • Size: 3.3 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.5.tar.gz
Algorithm Hash digest
SHA256 201e63efa47fe33479e923acfc790e5b6320f612a940f8bc6b6f964357df5119
MD5 3f67d5b00d8f050409dc842c01507e16
BLAKE2b-256 74eea29bbd8155ae737e58c8887c8efc40a9d0e3524d1c3f7ba1dc1f002109fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for task_multiprocess-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f319ab12da8215c2ea2aad6bce9a19cc20f93935ea11ce095da86433ca629367
MD5 dcd886a9697428953d1bab19f3bbaefb
BLAKE2b-256 705b60333c24f163c708af2ddceaf3d052791684fa9c455280a26eb761f62226

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