Skip to main content

the best threadpool pack.

Project description

You can implement thread pools by adding a single line of code without changing the order of any previous code.

import vthread

@vthread.pool(3) # just use this line to make pool, Create a threadpool with three threads
def crawl(i):
    import time;time.sleep(1) # Simulation time consuming
    print("crawl_url:",i)

urls = ["http://url1",
        "http://url2",
        "http://url3",
        "http://url4"]

for u in urls:
    crawl(u) # This function becomes a function that adds the original function to the thread pool.

It provides a method for grouping the thread pool

import vthread
pool_1 = vthread.pool(5,gqueue=1) # open a threadpool with 5 threads named 1
pool_2 = vthread.pool(2,gqueue=2) # open a threadpool with 2 threads named 2

@pool_1
def foolfunc1(num):
    time.sleep(1)
    print(f"foolstring1, test3 foolnumb1:{num}")

@pool_2
def foolfunc2(num):
    time.sleep(1)
    print(f"foolstring2, test3 foolnumb2:{num}")

@pool_2
def foolfunc3(num):
    time.sleep(1)
    print(f"foolstring3, test3 foolnumb3:{num}")

for i in range(10): foolfunc1(i)
for i in range(4): foolfunc2(i)
for i in range(2): foolfunc3(i)
# default gqueue is 0

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

vthread-0.1.5-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file vthread-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: vthread-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for vthread-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0b9a7101170a51c5c5d9d2b287367a52821c4f22ab701a184591b7dab84c9b0b
MD5 500a677c3ef978f1caf4522d6feff119
BLAKE2b-256 977b3d3944cc5de9e443253b860ecdfcee8098ca6afded234cf28df363f1bbb3

See more details on using hashes here.

Supported by

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