ptthreads
Project description
PTTHREADS
Library for easy threading
Installation
pip install ptthreads
How to use
import ptthreads into your script, and call it's functions.
Usage examples
# Example of process items from list
from ptthreads import ptthreads
def my_function(item):
print(item)
return item
my_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
threads = 20
thread_obj = ptthreads.ptthreads()
result = thread_obj.threads(my_list, my_function, threads)
print(result)
# Example of process items from text file
from ptthreads import ptthreads
def my_function(item):
print(item)
return item
threads = 20
thread_obj = ptthreads.ptthreads()
try:
with open("dict.txt", "r") as f:
items = [i.strip() for i in f.readlines()]
result = thread_obj.threads(items, my_function, threads)
print(result)
except Exception as e:
exit(e)
Printlock
To avoid overlapping prints between threads, save output to printlock
# Example of printlock
from ptthreads import ptthreads
def my_function(item):
printlock = ptthreads.printlock()
printlock.add_string_to_output(item)
printlock.add_string_to_output("Some text")
printlock.add_string_to_output("Some more text")
printlock.lock_print_output()
return item
my_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
threads = 20
thread_obj = ptthreads.ptthreads()
result = thread_obj.threads(my_list, my_function, threads)
Version History
- 0.0.1
- Alpha release
License
Copyright (c) 2020 HACKER Consulting s.r.o.
ptthreads is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ptthreads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ptthreads. If not, see https://www.gnu.org/licenses/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ptthreads-0.0.5.tar.gz
.
File metadata
- Download URL: ptthreads-0.0.5.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7660ab1b54a83076195b049728e3f52a3b5fc2aae6b495d65dd8e02a7eadbde |
|
MD5 | e1e093fc0ae87266b960b29af257c7ba |
|
BLAKE2b-256 | 669373c2d79db09056e042a707f6c124fbbb08fa42d6f9e433883c99605fb4ee |
File details
Details for the file ptthreads-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: ptthreads-0.0.5-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a8cab2fee22328fb4057265c4cde59da0236b341058d8d227d6089584c9d310 |
|
MD5 | f0ad987cb91df6b9426b41c01e8dfc0b |
|
BLAKE2b-256 | 4c05dab8da6c78a33a32c4cb6b756967f20d81e7aae53a1b11456082ada24356 |