From 968cd6358b531084f479a4332fd80f621a9fc55d Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Fri, 15 Apr 2022 14:02:09 +0300 Subject: [PATCH] Initial commit --- LICENSE.txt | 11 +++++++++++ README.md | 19 +++++++++++++++++++ __init__.py | 3 +++ setup.py | 18 ++++++++++++++++++ thread.py | 10 ++++++++++ 5 files changed, 61 insertions(+) create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 __init__.py create mode 100644 setup.py create mode 100644 thread.py diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a470929 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,11 @@ +Copyright 2021 BarsTiger + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5831620 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# thread +Smallest library that every project needs! + +It just... Runs your function in new thread with decorator! + +```bash +pip install thread +``` + +# Use +```python +from thread import threaded + +@threaded +def func(): + print("Printed from new thread!") +func() +``` + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..fb66427 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +# The smallest library for every python project! + +from thread import * diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3aced7a --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup( + name="thread", + version="1.0.0", + scripts=["thread.py"], + author="BarsTiger", + description="Small decorator library for launching threads", + long_description=long_description, + py_modules=["thread"], + license='MIT', + url='https://github.com/BarsTiger/thread', + long_description_content_type="text/markdown", + keywords=["threading", "thread", "decorator", "crossplatform"] +) diff --git a/thread.py b/thread.py new file mode 100644 index 0000000..7264930 --- /dev/null +++ b/thread.py @@ -0,0 +1,10 @@ +import threading + + +def threaded(func): + """ + Decorator to start a function in a new thread + """ + def thr(*args, **kwargs): + threading.Thread(target=func, args=(*args,), kwargs={**kwargs, }).start() + return thr