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.4.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.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: task_multiprocess-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 6fa3250f4b2060d278e842f8177cea7bf61e81bbef23a5f54c7f141e5e966409
MD5 5e6453238672baf9abd1cac0c83b987c
BLAKE2b-256 a94c3b8e2e70f49f5c99574ad7860e644802d8a0685262fb29f0931b673eac71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for task_multiprocess-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9952c8d55f05b938f76a61eb297fa1651143a8897dde31ee8ee1237e7ee5ff9e
MD5 02226b2b0aa8aa587e52f8b0a52d9aee
BLAKE2b-256 3efb5f4c3b2d9d0314225e44a61207f8c91dc515da903f9e031f1e308fc06099

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