catching signals in an object

H

hg

Hi,

I need to catch a signal "SIGUSR1" in an object ... and I need the signal
def that traps is to access the object context ... is that possible ?
(*nix and windows)

ex:

class test:
def __init__(self):
self.Set_Signal()

def Set_Signal(self):
import signal
signal.signal(..., Func)
def Func(.....):
#I need to get access to self


or can signal.signal take a method as param ?

Thanks

hg
 
R

robert

hg said:
Hi,

I need to catch a signal "SIGUSR1" in an object ... and I need the signal
def that traps is to access the object context ... is that possible ?
(*nix and windows)

ex:

class test:
def __init__(self):
self.Set_Signal()

def Set_Signal(self):
import signal
signal.signal(..., Func)
def Func(.....):
#I need to get access to self


or can signal.signal take a method as param ?

Just do it! Python is a functional language.
You have access to self (search for the term "closure") and
self.method is bound - thus a 'function'

objects are nothing special in Python.


Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top