mentby.com
Blog | Jobs | Help | Signup | Login

loading

python question for the list

Thu, 16 May 2013 05:18:46 -0700 Post Comments

Hi all,

i've got a rather puzzling python coding problem that I'm trying to solve
and I figured I'd ask the list for assistance.

If I have code that looks something like this:

import daemon

class bar():
    def func():
         print "Hello World!\n"

def sigusr1_handler(signum,frame):
    foo.func()

def main():
    foo = bar()

context = daemon.DaemonContext()
context.signal_map = {
    signal.SIGUSR1: sigusr1_handler
}
with context:
    if (__name__="__main__"):
        main()

Basically, this code becomes a daemon process and defines a signal handler
for SIGUSR1 which calls a method from class bar as instantiated by foo.

Unfortunately, this doesn't work.  When the signal handler gets called,
python throws a NameError and says that global name "foo" is not defined.

anybody know how I can get the python interpreter to recognize the foo
variable in the signal handler?  I tried using __main__.foo.func() but that
didn't work either.

Any help appreciated.

Thanks,

Braun Brelin
--
Irish Linux Users' Group mailing list
About this list :  http://mail.linux.ie/mailman/listinfo/ilug
Who we are :  http://www.linux.ie/
Where we are :  http://www.linux.ie/ map/

Read more »

Update to XEN question

Wed, 10 Apr 2013 09:24:25 -0700 Post Comments

Adding a line to the domain config file located in /etc/xen :
extra = 'console = tty1'

fixed the problem.

Now I need to figure out why the boot hangs on udevd.  :-)

Braun
--
Irish Linux Users' Group mailing list
About this list :  http://mail.linux.ie/mailman/listinfo/ilug
Who we are :  http://www.linux.ie/
Where we are :  http://www.linux.ie/ map/
Hi all,

I've been trying to set up Xen VM's and I've run into a problem.

I run xen-create-image <lots of params> --dist=precise --mirror=< http://ftp.heanet.ie/mirrors/ubuntu> >

I was assuing that the xen-create-image would actually download and install
precise pangolin on the VM.  The logs indicate that the software is
downloaded and authenticated.  however, once I run xm create <config_file>
and then try to connect with an xm console <domain>, I
immediately run into the Ubuntu installer screen.

Why isn't xen-create-image actually installing Ubuntu on the LVM disk
image?

Thanks,

Braun
--
Irish Linux Users' Group mailing list
About this list :  http://mail.linux.ie/mailman/listinfo/ilug
Who we are :  http://www.linux.ie/
Where we are :  http://www.linux.ie/ map/
Group(s)
Recent discussion with
Profile Widget
Copy and paste this HTML code to your blog or website: