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 7939671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:10:23+00:00 2026-06-03T23:10:23+00:00

I have a Jython script that I run as a daemon. It starts up,

  • 0

I have a Jython script that I run as a daemon. It starts up, logs into a server and then goes into a loop that checks for things to process, processes them, then sleeps for 5 seconds.

I have a cron job that checks every 5 minutes to make sure that the process is running and starts it again if not.

I have another cron job that once a day restarts the process no matter what. We do this because sometimes the daemon’s connection to the server sometimes gets screwed up and there is no way to tell when this happens.

The problem I have with this “solution” is the 2nd cron job that kills the process and starts another one. Its okay if it gets killed while it is sleeping but bad things might happen if the daemon is in the middle of processing things when it is killed.

What is the proper way to stop a daemon process… instead of just killing it?

Is there a standard practice for this in general, in Python, or in Java?
In the future I may move to pure Python instead of Jython.

Thanks

  • 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-03T23:10:24+00:00Added an answer on June 3, 2026 at 11:10 pm

    You can send a SIGTERM first before sending SIGKILL when terminating the process and receive the signal by the Jython script.

    For example, send a SIGTERM, which can be received and processed by your script and if nothing happens within a specified time period, you can send SIGKILL and force kill the process.

    For more information on handling the events, please see the signal module documentation.

    Also, example that may be handy (uses atexit hook):

    #!/usr/bin/env python
    
    from signal import signal, SIGTERM
    from sys import exit
    import atexit
    
    def cleanup():
        print "Cleanup"
    
    if __name__ == "__main__":
        from time import sleep
        atexit.register(cleanup)
    
        # Normal exit when killed
        signal(SIGTERM, lambda signum, stack_frame: exit(1))
    
        sleep(10)
    

    Taken from here.

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

Sidebar

Related Questions

Basically I have a script in Python that grabs the text from an open
We have an existing java-based heavyweight project that needed an interactive script interpreter. After
I have a simple Jython GUI that displays an XML file in a JTree.
I have a Java project that utilizes Jython to interface with a Python module.
I have a Jython script properly running on a Windows 7 machine with PostgreSQL
As part of an automated test, I have a python script that needs to
I am writing a Jython script to sort a list of URLs. I have
Trying to blur a picture in Jython. What I have does run but does
myRs=myStmt.executeQuery(select i_col,col_name from tab_col) i=0 while (myRs.next()): list= myRs.getString(I_COL)+','+myRs.getString(COL_NAME) i have a jython code
I notice this thread: Fastish Python/Jython IPC , and I have a similar problem,

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.