Skip to main content

Native threading for Python using C++ and pybind11

Project description

Smuxent

v0.0.2 Smuxent is a lightweight native threading module for Python, backed by C++ and pybind11.
It allows you to easily launch background threads in Python using true native threads - with cooperative control and ID tracking.

This project was built for fun, learning, and utility. If you're using this, thanks! Feedback and suggestions are welcome though not sure where that'd be.

Currently supports: Python 3.11.x-3.12.x on Windows (x64 and x86)


What It Does

  • Run Python functions in detached threads
  • Create and run thread pools
  • Track threads by ID
  • Submit tasks to said thread pools
  • Kill individual threads or all running threads
  • Track thread IDs and check if they are alive
  • Automatically loads the correct native extension based on system architecture

Example

from Smuxent import hello_thread, basic_thread

hello_thread(3)  # prints "Hello, Thread!" three times on another thread

def my_func():
    print("Running on another thread")

thread_id = basic_thread(my_func)  # runs my_func() on another thread, returning the thread ID

All Existing Functions

# === v0.0.1 - Basic Threading ===

def basic_thread(func: Callable, *args: Any) -> int: ...
def hello_thread(loop_count: int = 1) -> int: ...

def is_alive(id: int) -> bool: ...
def kill_thread(id: int) -> None: ...
def kill_all_threads() -> None: ...
def get_all_thread_ids() -> List[int]: ...

# === v0.0.2 - Thread Pools ===

def thread_pool(size: int) -> str: ...
def submit(pool_id: str, func: Callable, *args: Any) -> bool: ...
def get_pool_thread_ids(pool_id: str) -> List[int]: ...
def kill_pool(pool_id: str) -> None: ...

# === Deprecated / Legacy Functions ===

def __basic_threadOld(func: Callable, *args: Any) -> None:
    """[Deprecated] Use basic_thread instead. This version does not return a thread ID."""

def __hello_threadOld(loop_count: int = 1) -> None:
    """[Deprecated] Use hello_thread instead. This version does not support thread tracking."""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smuxent-0.0.2.tar.gz (335.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smuxent-0.0.2-py3-none-any.whl (335.1 kB view details)

Uploaded Python 3

File details

Details for the file smuxent-0.0.2.tar.gz.

File metadata

  • Download URL: smuxent-0.0.2.tar.gz
  • Upload date:
  • Size: 335.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for smuxent-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cbbe7d3a96ec67be804cca54a5a8ef5a6cb65bf66aa504b974d3c324ad7c4622
MD5 93e562de99adeb8362914faea652f486
BLAKE2b-256 55fa2d4701312baed76970805e02b7a7fb2f4e5b6aedcacc6ab9c95fc58a18c6

See more details on using hashes here.

File details

Details for the file smuxent-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: smuxent-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 335.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for smuxent-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7669c99e5fe0c36235211aa4d0a27d6545ba1f72e181863434442568dd4c245f
MD5 b988ec5bc37bfea364e9363ca69e9687
BLAKE2b-256 3d438ffc43bdfa4144488b07e0016f5689838e2662fdc64e8dc7be9ca71ec1dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page