Simple example python program that send a signal between two threads

import gobject

import threading

import time

class knight(gobject.GObject):

__gsignals__ = { 'chicken': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,

                               (str,)) }

def __init__(self) :

    #Call super()

    gobject.GObject.__init__(self)

    #Do your initialization here

    #This is only an example

    a = None

class tv_speaker :

def __init__(self,emiter) :

    self.emiter = emiter

    self.emiter.connect("chicken",self.do)

def do(self,param1,param2) :

    print "receiving the chicken on the head : my brain hurt"

    time.sleep(2)

    print "And now for something completely %s" %param2

k = knight()

tv = tv_speaker(k)

k.emit("chicken","different")

k.emit("chicken","random")

Proxy Information
Original URL
gemini://ploum.be/files/old/signal/signal1.py
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
155.44221 milliseconds
Gemini-to-HTML Time
0.320918 milliseconds

This content has been proxied by September (ba2dc).