Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:12:46+00:00 2026-06-17T21:12:46+00:00

I am trying to create small notify daemon pynotify works in main thread But

  • 0

I am trying to create small notify daemon

pynotify works in main thread
But pynotify does not work in daemon run-cycle. After show method program just waits something
I took daemon sample here:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

My daemon:

import pynotify
import sys, time
from daemon import Daemon
class NotifyDaemon(Daemon):
    def run(self):
        i = 9
        while True:
            pynotify.init('icon-summary-body')
            n = pynotify.Notification('Test', 'text ')
            print 'Test from stdout'# OK but only one message
            n.show() # not OK
            time.sleep(1)
if __name__ == "__main__":
    if not pynotify.init('icon-summary-body'):
        print 'PyNotify init failed!'
        exit(2)
    daemon = NotifyDaemon('/tmp/reminderdaemon.pid', stdout='/dev/stdout')
    if len(sys.argv) == 2:
        if 'start' == sys.argv[1]:
            n = pynotify.Notification('Daemon starts!')#this message is ok
            n.show()# OK
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            daemon.restart()
        else:
            print "Unknown command"
            sys.exit(2)
        sys.exit(0)
    else:
        print "usage: %s start|stop|restart" % sys.argv[0]
        sys.exit(2)

OS:Ubuntu WM: Awesome

Is there a way out?
PS sorry for my writing mistakes. English in not my native language

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:12:47+00:00Added an answer on June 17, 2026 at 9:12 pm

    You can ditch the daemonization code. If you want a process that runs on boot then use upstart. All you need to do is place a file in /etc/init/my_server.conf that contains something like this:

    description "My Server"
    author "Dark Daiver dark@dd.com"
    
    start on runlevel [2345]
    stop on runlevel [!2345]
    
    respawn
    
    exec python /home/dd/my_server.py 
    

    That will do a respawn if the process dies as well.

    So if all you had in your my_server.py file was:

    import pynotify
    
    
    if __name__ == "__main__":
    
       pynotify.init('icon-summary-body')
       n = pynotify.Notification('Test', 'text ')
    
       while True:
            n.show() # not OK
            time.sleep(1)
    

    That would start on boot and show a notification once a second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not much good in jQuery/javascript but trying to create a small game. here is
I am trying to create a small email apps. Everything works correctly but the
I'm trying create a small http proxy service. This is not working so well.
I'm trying to create small application on Yii framework but can't understand one moment.
I'm trying to create a small HTTP server in C# but I'm having some
I'm trying to create a small program to run on a centralized device. This
I'm trying to create a small sequence of animations with jQuery but cannot get
I'm trying to create a small flash-app, which needs to run as big as
So I'm just trying to create a small website. (Don't worry that's not going
I'm trying to create a small slider where jquery UI Scale brings out and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.