Skip to main content

Signal for Python

Project description

Thread Safe Signal

Thread safe signal to generate and receive events

Installation:

pip install pyrvsignal

Example code:

import time
from threading import Thread
from pyrvsignal import Signal


class MyThread(Thread):
    started = Signal()
    finished = Signal()

    def __init__(self, target, args):
        self.target = target
        self.args = args
        Thread.__init__(self)

    def run(self) -> None:
        self.started.emit()
        self.target(*self.args)
        self.finished.emit()


def do_my_work(details):
    print(f"Doing work: {details}")
    time.sleep(10)

def started_work():
    print("Started work")
    
def finished_work():
    print("Work finished")

thread = MyThread(target=do_my_work, args=("testing",))
thread.started.connect(started_work)
thread.finished.connect(finished_work)
thread.start()

Contact

  If any suggestions mail to ravikiranb36@gmail.com

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

pyrvsignal-2023.8.1.tar.gz (2.1 kB view details)

Uploaded Source

File details

Details for the file pyrvsignal-2023.8.1.tar.gz.

File metadata

  • Download URL: pyrvsignal-2023.8.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.0

File hashes

Hashes for pyrvsignal-2023.8.1.tar.gz
Algorithm Hash digest
SHA256 8626fda2c6df86af98c6d30f4f0d15a1b3ff08d4e1f7030b9d18d6e57c0eaff7
MD5 eb718e13a492340dc65f531705bb9396
BLAKE2b-256 31042e91a94ed0b24008ca5f8fd98fe6e3676e76a3beceecad6954eee928dd46

See more details on using hashes here.

Supported by

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