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

  • Home
  • SEARCH
  • 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 8084575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:50:27+00:00 2026-06-05T17:50:27+00:00

I have a python script that I want always to run in the background.

  • 0

I have a python script that I want always to run in the background. What the application does is that it goes to a Oracle database and checks if there is a message to be displayed to the user and if there is, use the pynotify to display a notification.

I tried using a Timer object but it only invoke the method after the selective time. I want it to invoke every time after the selective time.

if __name__ == '__main__':
  applicationName = "WEWE"
    # Initialization of the Notification library
  if not pynotify.init(applicationName):
   sys.exit(1)         

  t = threading.Timer(5.0, runWorks)
  t.start() 

Will doing this work and is there a better way?

 if __name__ == '__main__':
      applicationName = "WEEWRS"
        # Initialization of the Notification library
      if not pynotify.init(applicationName):
       sys.exit(1)         
      while True:
       t = threading.Timer(5.0, runWorks)
       t.start() 

But that gave me another problem.

thread.error: can't start new thread

(r.py:12227): GLib-ERROR **: creating thread 'gdbus': Error creating thread: Resource temporarily unavailable
  • 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-05T17:50:28+00:00Added an answer on June 5, 2026 at 5:50 pm

    I solved the problem reducing the creation of strings. The below error –

    thread.error: can't start new thread
    
    (r.py:12227): GLib-ERROR **: creating thread 'gdbus': Error creating thread: Resource temporarily unavailable
    

    comes when there is a lack of resources. Below is the corrected code.

    if __name__ == '__main__':
      applicationName = "DSS POS"
      # Initialization of the Notification library
      if not pynotify.init(applicationName):
       sys.exit(1)         
    
      flagContinous = True
      timeout = 5
      # This loop will continously keep the application in the background
      while flagContinous:
       time.sleep(timeout)
       runWorks()
      # After 30 seconds, "hello, world" will be printed  
    

    I also used a lock file so that the script won’t run multiple-times.

    pid = str(os.getpid())
      pidfile = "/tmp/mydaemon.pid"
    
      # If we have a lock already block the program
      if os.path.isfile(pidfile):
        print "%s already exists, exiting" % pidfile
        sys.exit()
      else:
        file(pidfile, 'w').write(pid)
      # Do all the work
      applicationName = "DSS POS"
      # Initialization of the Notification library
      if not pynotify.init(applicationName):
       sys.exit(1)         
    
      # Controls for the application
      flagContinous = True
      timeout = 5
      # This loop will continously keep the application in the background
      while flagContinous:
       time.sleep(timeout)
       runWorks()
      # After 30 seconds, "hello, world" will be printed  
    
      # Release the file
      os.unlink(pidfile)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Iron Python script that I want to run and then have
I have created a Python script that I want to run daily via a
I have a python script that i want to run from the command line
I have a python script that want to ping a few (quite a few!)
I have a python script that I want to debug with python-mode . I
Suppose I have a perl (or python) script that does something highly secretive; I'd
I have a Python script that I want to use as a controller to
I have a simple Python script that I want to stop executing if a
I made a .pyw python script that I want to have running in the
I have a Python script that does something along the line of: def MyScript(input_filename1,

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.