### Build and install thread from source Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Clones the thread repository from GitHub and installs the package locally using pip. ```sh # Clone this repository git clone https://github.com/python-thread/thread # Install the upstream package pip install -e . ``` -------------------------------- ### Set up thread for development Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Clones the thread repository, installs Poetry, and then installs project dependencies using Poetry for development purposes. ```sh # Clone this repository git clone https://github.com/python-thread/thread # Install poetry pip install poetry # Install dependencies poetry install ``` -------------------------------- ### Install thread using pip Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Installs the thread library using pip, a common Python package installer. ```sh pip install thread ``` -------------------------------- ### Build and install thread from source Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Clones the thread repository from GitHub and installs the package locally using pip. ```sh # Clone this repository git clone https://github.com/python-thread/thread # Install the upstream package pip install -e . ``` -------------------------------- ### Set up thread for development Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Clones the thread repository, installs Poetry, and then installs project dependencies using Poetry for development purposes. ```sh # Clone this repository git clone https://github.com/python-thread/thread # Install poetry pip install poetry # Install dependencies poetry install ``` -------------------------------- ### Install thread using pip Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Installs the thread library using pip, a common Python package installer. ```sh pip install thread ``` -------------------------------- ### Import thread in Python Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Demonstrates how to import the thread library into a Python script after installation. ```py import thread ``` -------------------------------- ### Setup Thread CLI for Development Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/command-line-interface.mdx Steps to set up the Thread CLI for development, including cloning the repository, installing Poetry, and installing project dependencies. ```sh # Clone this repository git clone https://github.com/python-thread/thread-cli # Install poetry pip install poetry # Install dependencies poetry install ``` -------------------------------- ### Install thread using pipx Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Installs the thread library using pipx, which allows running Python applications in isolated environments. ```sh pipx install thread ``` -------------------------------- ### Setup Thread CLI for Development Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/command-line-interface.mdx Clones the thread-cli repository, installs Poetry, and then installs project dependencies. ```sh # Clone this repository git clone https://github.com/python-thread/thread-cli # Install poetry pip install poetry # Install dependencies poetry install ``` -------------------------------- ### Install thread using poetry Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/installation.mdx Adds the thread library as a dependency to a project managed by Poetry, a Python dependency management tool. ```sh poetry add thread # OR poetry install thread ``` -------------------------------- ### Import thread in Python Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Demonstrates how to import the thread library into a Python script after installation. ```py import thread ``` -------------------------------- ### Install thread using pipx Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Installs the thread library using pipx, which allows running Python applications in isolated environments. ```sh pipx install thread ``` -------------------------------- ### Install thread using poetry Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/installation.mdx Adds the thread library as a dependency to a project managed by Poetry, a Python dependency management tool. ```sh poetry add thread # OR poetry install thread ``` -------------------------------- ### Project Header and Navigation (React) Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/index.mdx This snippet demonstrates the main header section of the project, including the project title, version, a package manager component, and a 'Get Started' button. It also includes a smooth scroll button to navigate to the features section. ```javascript
Now
14 July 2024
7 July 2024
27 May 2024
25 May 2024
28 April 2024
21 April 2024
17 March 2024
{children}
); } ``` -------------------------------- ### Testing with Pytest and npm Source: https://github.com/python-thread/thread/blob/main/CONTRIBUTING.md Commands to run tests for the project. It supports both Pytest for Python code and npm for other project dependencies. ```sh # To test your code, run: npm test # Or pytest -sv . ``` -------------------------------- ### Initializing a Thread (Decorated Function) Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/thread-class.mdx Explains how to use the @thread.threaded decorator to automatically run a function in a new thread. ```python import thread @thread.threaded def my_target(): ... worker = my_target() # thread.Thread() ``` -------------------------------- ### Initializing a Thread (Decorated Function) Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/v1/thread-class.mdx Explains how to use the @thread.threaded decorator to automatically run a function in a new thread. ```python import thread @thread.threaded def my_target(): ... worker = my_target() # thread.Thread() ``` -------------------------------- ### Type-Annotated Thread Function Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/learn/examples/threading.mdx Illustrates how to use Python's type annotations with the `thread` library for functions running in separate threads. This enhances code readability and helps catch type errors early. ```python import thread def background_function(x: int) -> int: return x + 1 worker = Thread(target=background_function, args=(5,)) worker.start() returned = worker.get_return_value() # int ``` -------------------------------- ### ConcurrentProcessing Methods Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/concurrent-processing.mdx This section documents the methods of the ConcurrentProcessing class, which are used to manage and control the execution of threads for concurrent processing. It covers starting threads, checking their status, retrieving results, waiting for completion, and terminating them. ```APIDOC ConcurrentProcessing: start() -> None Description: Starts the concurrent processing. Usage: worker.start() Exceptions Raised: ThreadStillRunningError is_alive() -> bool Description: Checks if the threads are still alive. Usage: worker.is_alive() Exceptions Raised: ThreadNotInitializedError get_return_values() -> List[Data_Out] Description: Halts thread execution until processing completes and returns the value returned by the function. Usage: worker.get_return_values() Exceptions Raised: ThreadNotInitializedError, ThreadNotRunningError join(timeout: float = None) -> None Description: Halts thread execution until the ConcurrentProcessing completes or exceeds the timeout. A None value for timeout is equivalent to float("inf"). Usage: worker.join(5) Exceptions Raised: ThreadNotInitializedError, ThreadNotRunningError kill(yielding: bool = False, timeout: float = 5) -> bool Description: Schedules threads to be killed. If yielding is True, halts execution until threads are killed or timeout is exceeded. A None value for timeout is equivalent to float("inf"). Usage: worker.kill(True, 10) Exceptions Raised: ThreadNotInitializedError, ThreadNotRunningError Warning: Only schedules threads to be killed; does not immediately kill them. Killing occurs after the current line of execution in the target thread. ``` -------------------------------- ### Decorated Functions for Background Processing Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/learn/examples/processing.mdx Illustrates using the `@thread.processor` decorator to automatically run functions in separate threads. When a decorated function is called, it spawns a new thread and runs in the background. The example shows how to join the worker and retrieve results. ```python import time import thread @thread.processor def my_processor(x): time.wait(5) print('My processing task is complete.') return x worker = my_background_task([1, 2, 3]) print('Started processing task.') worker.join() worker.get_return_values() # [1, 2, 3] # Terminal output: # > Started processing task. # > My processing task is complete. ``` -------------------------------- ### Thread CLI Help Command Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/command-line-interface.mdx Opens the issue tracker in a web browser or prints the link if the browser cannot be opened. ```sh thread help ``` -------------------------------- ### Thread CLI Configuration Command Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/docs/latest/command-line-interface.mdx Placeholder command for future configuration options. ```sh thread config ``` -------------------------------- ### Feature Component (React) Source: https://github.com/python-thread/thread/blob/main/docs/src/pages/index.mdx A React component designed to display features with a title, description, optional version, and a 'Read More' link. It includes dynamic styling for a gradient background effect on hover. ```javascript export function Feature({ title, description, version = false, href = false, ...props }) { return ({version}
) : ( )}{title}
{description}
{href && ( Read More