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/.
Metadata
Release files for ptthreads 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ptthreads-0.0.5.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ptthreads-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / ptthreads-0.0.5.tar.gz
| Download URL | ptthreads-0.0.5.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7660ab1b54a83076195b049728e3f52a3b5fc2aae6b495d65dd8e02a7eadbde
|
|
BLAKE2b-256 checksum How to use checksums |
669373c2d79db09056e042a707f6c124fbbb08fa42d6f9e433883c99605fb4ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / ptthreads-0.0.5-py3-none-any.whl
| Download URL | ptthreads-0.0.5-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a8cab2fee22328fb4057265c4cde59da0236b341058d8d227d6089584c9d310
|
|
BLAKE2b-256 checksum How to use checksums |
4c05dab8da6c78a33a32c4cb6b756967f20d81e7aae53a1b11456082ada24356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|