Socket
Socket
Sign inDemoInstall

threading-manager

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

threading-manager

manage spawned threads


Maintainers
1

threading_manager (v0.0.8)

DESCRIPTION_SHORT

Manage spawned threads

DESCRIPTION_LONG

designed to working with spawned threads

Features

  1. use different managers for different funcs/methods if needed
  2. use just one decorator to spawn threads from func / methods
  3. keep all spawned threads in list by ThreadItem objects
  4. ThreadItem keeps result/exx/is_alive attributes!
  5. use wait_all()

License

See the LICENSE file for license rights and limitations (MIT).

Release history

See the HISTORY.md file for release history.

Installation

pip install threading-manager

Import

from threading_manager import *

USAGE EXAMPLES

See tests and sourcecode for other examples.


1. example1.py

from threading_manager import *

count = 5
time_start = time.time()


# define victim ------------------
class ThreadManager1(ThreadsManager):
    pass


class Cls:
    @ThreadManager1().decorator__to_thread
    def func1(self, num):
        time.sleep(1)
        return num * 1000


# spawn ------------------
for i in range(count):
    assert Cls().func1(i) is None

assert ThreadManager1().count == count
ThreadManager1().wait_all()
assert {item.result for item in ThreadManager1().THREADS} == {num * 1000 for num in range(count)}

ThreadManager1().clear()

# spawn ------------------
for i in range(count):
    assert Cls().func1(i) is None

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc