threaded
threaded is a set of decorators, which wrap functions in:
concurrent.futures.ThreadPool
threading.Thread
asyncio.Task in Python 3.
Why? Because copy-paste of loop.create_task, threading.Thread and thread_pool.submit is boring, especially if target functions is used by this way only.
Pros:
Free software: Apache license
Open Source: https://github.com/python-useful-helpers/threaded
PyPI packaged: https://pypi.python.org/pypi/threaded
Tested: see bages on top
Decorators:
ThreadPooled - native concurrent.futures.ThreadPool.
threadpooled is alias for ThreadPooled.
Threaded - wrap in threading.Thread.
threaded is alias for Threaded.
AsyncIOTask - wrap in asyncio.Task. Uses the same API, as ThreadPooled.
asynciotask is alias for AsyncIOTask.
Usage
ThreadPooled
Mostly it is required decorator: submit function to ThreadPoolExecutor on call.
threaded.ThreadPooled.configure(max_workers=3)
@threaded.ThreadPooled
def func():
pass
concurrent.futures.wait([func()])
Usage with asyncio:
loop = asyncio.get_event_loop()
@threaded.ThreadPooled(loop_getter=loop, loop_getter_need_context=False)
def func():
pass
loop.run_until_complete(asyncio.wait_for(func(), timeout))
Python 3.5+ usage with asyncio and loop extraction from call arguments:
loop_getter = lambda tgt_loop: tgt_loop
@threaded.ThreadPooled(loop_getter=loop_getter, loop_getter_need_context=True) # loop_getter_need_context is required
def func(*args, **kwargs):
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait_for(func(loop), timeout))
During application shutdown, pool can be stopped (while it will be recreated automatically, if some component will request).
threaded.ThreadPooled.shutdown()
Threaded
Classic threading.Thread. Useful for running until close and self-closing threads without return.
Usage example:
@threaded.Threaded
def func(*args, **kwargs):
pass
thread = func()
thread.start()
thread.join()
Without arguments, thread name will use pattern: 'Threaded: ' + func.__name__
Override name can be don via corresponding argument:
@threaded.Threaded(name='Function in thread')
def func(*args, **kwargs):
pass
Thread can be daemonized automatically:
@threaded.Threaded(daemon=True)
def func(*args, **kwargs):
pass
Also, if no any addition manipulations expected before thread start, it can be started automatically before return:
@threaded.Threaded(started=True)
def func(*args, **kwargs):
pass
AsyncIOTask
Wrap in asyncio.Task.
usage with asyncio:
@threaded.AsyncIOTask
def func():
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait_for(func(), timeout))
Provide event loop directly:
loop = asyncio.get_event_loop()
@threaded.AsyncIOTask(loop_getter=loop)
def func():
pass
loop.run_until_complete(asyncio.wait_for(func(), timeout))
Usage with loop extraction from call arguments:
loop_getter = lambda tgt_loop: tgt_loop
@threaded.AsyncIOTask(loop_getter=loop_getter, loop_getter_need_context=True)
def func(*args, **kwargs):
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait_for(func(loop), timeout))
Testing
The main test mechanism for the package threaded is using tox. Available environments can be collected via tox -l
CI systems
For code checking several CI systems is used in parallel:
GitHub actions: is used for checking: PEP8, pylint, bandit, installation possibility and unit tests.
coveralls: is used for coverage display.
CD system
GitHub actions: is used for package delivery on PyPI.
Metadata
Release files for threaded 4.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| threaded-4.2.0.tar.gz | 30.1 kB | Without provenance | Details for threaded-4.2.0.tar.gz |
Built distributions (wheels)
Total release size: 16.1 MB
Release files / threaded-4.2.0.tar.gz
| Download URL | threaded-4.2.0.tar.gz |
|---|---|
| Size | 30.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83ad4f3826b465af8b56b373589b13eaebe2733a8772201ce4d1ad2ad2c52515
|
|
BLAKE2b-256 checksum How to use checksums |
78a4a89571c3e6c50dfc2087c33680775e66582c6a795237af4d264a63c78d15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-py3-none-any.whl
| Download URL | threaded-4.2.0-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38c1a05f30597b45f5fe83d561387626f6f24ff5954567e0a29d90083df22c1b
|
|
BLAKE2b-256 checksum How to use checksums |
1330e4de40c850009f821892d8a7683c806a43eb2c48a06241f1b087f7546022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp312-cp312-win_amd64.whl
| Download URL | threaded-4.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 184.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1ca6e8a3cc8886ce7a64eab9c477577220164aee9fdd27decfe20fb5e78e2871
|
|
BLAKE2b-256 checksum How to use checksums |
3e093d650820c9bee7736034e6d2ab084ce42487dcabfbf1f9408e7886a8b30a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | threaded-4.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee692bc4e8fd833dad32610342a6a0ede9e5dbd26e080abf56e9f62d322b05a5
|
|
BLAKE2b-256 checksum How to use checksums |
0d77d94173d6cdcc996989e7ba95cb1998db766a603ae5eff8cf8d7e4c948dfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | threaded-4.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
0d047f61d8df945af3904a233e094ae7ae285c7baefb97bac2b2ba9cee60d463
|
|
BLAKE2b-256 checksum How to use checksums |
3bf09b733946c44a3fd2cc700dcc112ddf18e8078b725a701240fa7439653a00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | threaded-4.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
4edbf0ccf76ac77b03334703ed85a8db25185405370c10a493bded70f3572ad3
|
|
BLAKE2b-256 checksum How to use checksums |
2a2bb301e867a25b5629123b840ff8fbc2ab5eedc2e20123482074dd08d43068
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp311-cp311-win_amd64.whl
| Download URL | threaded-4.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 185.4 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
04f769a5e5c3c251e64f4cf2c5d099d1327277fd7ab5874749501f1599f65de4
|
|
BLAKE2b-256 checksum How to use checksums |
422cc284b701df74137f559b4f8b24fdf1fff2c1d95f4a7c2a47d2eb687b13b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | threaded-4.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ed7419f4409b20b45ec07c8c8dbc59d47f86f8735871b7e1d995b22b548226c
|
|
BLAKE2b-256 checksum How to use checksums |
6279cf488cd0c9b5b167582167d5707e511415567cfdee4950b5108b9d3274c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | threaded-4.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
c8bc318d37078af559ccb5fcf63cfb979aa5207fa7a5e6e136aab546762884a4
|
|
BLAKE2b-256 checksum How to use checksums |
df520233e4fada165425fac006f63cb7f97a558962dada06e32f4a056d123817
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | threaded-4.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
14d59d028947221422b480eed89c86aca5a5015d70d59f1508a49c6be179c001
|
|
BLAKE2b-256 checksum How to use checksums |
c6d6db57bd2a5d71a99b966b9fc8bd07f1ad47e327712af0ec1ae8ce958226a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp310-cp310-win_amd64.whl
| Download URL | threaded-4.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 185.7 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6f4360a4ab56ac24450ef5a8696cb8defbdd11b0a9efe8cbc03213776e3d19d6
|
|
BLAKE2b-256 checksum How to use checksums |
dcd046cfd866f7a26bf885d9b422cd1f9d60ceb6d89c3b8372d53539050d275a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | threaded-4.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 948.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7550d788bc96e73a70821b481f376f2ebd7afdb40f395651374318cecdebe8e7
|
|
BLAKE2b-256 checksum How to use checksums |
ae96812f9b6545ca71c3cb39f732411435ececf6ee8517cee333419b32f34999
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | threaded-4.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 942.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
289b4b43a3675ddec5fcff189e53b0d42044b61d4fd2241e35ead5abc15db439
|
|
BLAKE2b-256 checksum How to use checksums |
109573199a901add89078c9620297cc76aa547e7aed9af77f651874526e2255e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | threaded-4.2.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 910.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
97418c1029796b35b709915435ea77443ef2565e07ac0c2e2bc6d76a9f013317
|
|
BLAKE2b-256 checksum How to use checksums |
0b4f47678cf8a27ef168f33f2f9d892ae4252f023aa18e2bb84c8c027c458884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp39-cp39-win_amd64.whl
| Download URL | threaded-4.2.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 188.1 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bbb618a80d79caadd7adfb3dff192681e363871fa12bf3e4ef49ee874e55fa91
|
|
BLAKE2b-256 checksum How to use checksums |
627b178c1a4a43071617b2e46c1b145171b882329a1b638c775d7edf26f932e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | threaded-4.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 959.2 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0a85db2d603bdb4da5ab6fdd475ade0f56820fe6d191bc647ef68b3983aa2f98
|
|
BLAKE2b-256 checksum How to use checksums |
cc8ac54e1b37c48f31a7e3fc7bea3414f4fff946bba4b25c5ce6e0a5d901516c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | threaded-4.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 953.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
7a8839c74e5d88ca7cba346cec394d30e5ec0002e7a59d718df9f2dd331d653d
|
|
BLAKE2b-256 checksum How to use checksums |
2a5634f80bfffd99493e3da90f66c712b0146dc95d2dea5c0a2b37bd88e2dc70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | threaded-4.2.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 921.6 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
00c1910f722d50e2717ffd5fe8c66e137766eb9c6d78a13992fec11697dc68b0
|
|
BLAKE2b-256 checksum How to use checksums |
2a393ffc37b58df6777a43b7d78578ed960799f764a67967d17be4f1a6274381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp38-cp38-win_amd64.whl
| Download URL | threaded-4.2.0-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 188.8 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a3fde9845f7704110d936687fd2b2b013e0822e5000907e05a900d98fd687ef9
|
|
BLAKE2b-256 checksum How to use checksums |
74005096b1c2146534c0744e0c7bc443af3936c1017a7c870d2ab32954a845a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | threaded-4.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 971.9 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b23ff0545f7b6458463c6d9baefee9239b9e6bf721d65099f173a4a5690eba63
|
|
BLAKE2b-256 checksum How to use checksums |
abdbbf098374b8231a62914665455ce246143488ad7ad9da8a039b4539537740
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | threaded-4.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 965.8 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
93f36eaf4b6880fc373633d2b4740be798d58298ae0b6b6dc598a1ded901922d
|
|
BLAKE2b-256 checksum How to use checksums |
ade16c6ddacf7ad11fb79a506534bd7aaf875a4401d0856161d1d79c6c878a56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / threaded-4.2.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | threaded-4.2.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 938.3 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
7c52ea5c2d631b64d8f616fc9360320844087fa5257353edc2d360330cbc467d
|
|
BLAKE2b-256 checksum How to use checksums |
5866fddec82a7b565f2420156eb64e1d229ac50d2c1a3515d6bc02c8f52a0245
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for threaded 4.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.