Python binding to growl and daemonizing

The Growl forums have moved to Google Groups, this forum is read only.
karguine
Harmless
Posts: 1
Joined: Thu Oct 01, 2009 5:51 pm

Python binding to growl and daemonizing

Postby karguine » Thu Oct 01, 2009 5:56 pm

Hi.
Im trying to write a little daemon in python which will use growl notifications. All works fine until my programm goes to deamonize. After daemonizing I get a crash message on my Snow Leopard system.

Im using python 2.6 from box. Growl is 1.2

How can i deal with it?

This is message:
Process: Python [71176]
Path: /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: ??? [1]

PlugIn Path: /Library/Python/2.6/site-packages/_growl.so
PlugIn Identifier: _growl.so
PlugIn Version: ??? (???)

Date/Time: 2009-10-01 21:54:47.166 +0400
OS Version: Mac OS X 10.6.1 (10B504)
Report Version: 6

Interval Since Last Report: 23595 sec
Crashes Since Last Report: 7
Per-App Crashes Since Last Report: 4
Anonymous UUID: 1035DEA9-8B6E-45C8-9443-0EC4435B4F57

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Application Specific Information:
*** single-threaded process forked ***


This is my little script:

Code: Select all

import time
import Growl

import daemonize

class MyNotifier(Growl.GrowlNotifier):
   applicationName = 'MyApplcation'
   notifications = ['ntf1']


growl = MyNotifier()
growl.register()

growl.notify('ntf1', 'Sent to juick', 'start')

daemonize.daemonize()
c = 0
while True:
   growl.notify('ntf1', 'Sent to juick', 'in loop')
   time.sleep(10)
   c += 1
   if c == 5: sys.exit()

This is daemonize module:

Code: Select all

import sys
import os

def daemonize (stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
    # Perform first fork.
    try:
        pid = os.fork( )
        if pid > 0:
            sys.exit(0) # Exit first parent.
    except OSError, e:
        sys.stderr.write("fork #1 failed: (%d) %sn" % (e.errno, e.strerror))
        sys.exit(1)
    # Decouple from parent environment.
    os.chdir("/")
    os.umask(0)
    os.setsid( )
    # Perform second fork.
    try:
        pid = os.fork( )
        if pid > 0:
         sys.exit(0) # Exit second parent.
    except OSError, e:
        sys.stderr.write("fork #2 failed: (%d) %sn" % (e.errno, e.strerror))
        sys.exit(1)
    # The process is now daemonized, redirect standard file descriptors.
    for f in sys.stdout, sys.stderr: f.flush( )
    si = file(stdin, 'r')
    so = file(stdout, 'a+')
    se = file(stderr, 'a+', 0)
    os.dup2(si.fileno( ), sys.stdin.fileno( ))
    os.dup2(so.fileno( ), sys.stdout.fileno( ))
    os.dup2(se.fileno( ), sys.stderr.fileno( ))

Return to “Growl”

Who is online

Users browsing this forum: No registered users