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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:34:26+00:00 2026-06-09T20:34:26+00:00

Is there a way to have CherryPy (running on :8080, it’s only function being

  • 0

Is there a way to have CherryPy (running on :8080, it’s only function being a listener for SIGUSR1) kill a process if it hasn’t been pinged in a certain number of seconds?

Certainly the Python code for process killing is not in question, simply the way CherryPy would detect the last ping, and constantly compare it to the current time – Killing a process if it hasn’t been pinged in a certain number of seconds.

Note that if Javascript is doing the pinging (via setInterval()), an infinite loop within the CherryPy code would cause the .ajax() request to hang and/or timeout, unless there is a way to have .ajax() only ping and not wait for any type of response.

Thanks for any tips you guys can provide!

Mason

  • 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-09T20:34:28+00:00Added an answer on June 9, 2026 at 8:34 pm

    Ok, so the answer was to set up two classes, one that updates the time, the other that constantly checks if the timestamp hasn’t been updated in 20 seconds. This is ULTRA useful when it comes to killing a process once your user leaves a page, if the entire site isn’t built on CherryPy. In my case, it is simply sitting on :8080 listening for JS pings from a Zend project. The CherryPy code looks like:

    import cherrypy
    import os
    import time
    
    class ProcKiller(object):
    
        @cherrypy.expose
        def index(self):
            global var 
            var = time.time()
    
        @cherrypy.expose
        def other(self):
            while(time.time()-var <= 20):
                time.sleep(1)
            print var
            os.system('pkill proc')     
    
    
    cherrypy.quickstart(ProcKiller())
    

    The JS that pings is literally as simple as:

    <script type="text/javascript">
    function ping(){
        $.ajax({
           url: 'http://localhost:8080'
        });
     }
    function initWatcher(){
        $.ajax({
           url: 'http://localhost:8080/other'
        });
     }
    
    ping(); //Set time variable first
    initWatcher(); //Starts the watcher that waits until the time var is >20s old
    setInterval(ping, 15000); //Updates the time variable every 15s, so that while users are on the page, the watcher will never kill the process
    </script>
    

    Hope that this helps someone else looking for a similar solution to process killing once users leave a page!

    Mason

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

Sidebar

Related Questions

Is there any way to have a function in PostgreSQL return an arbitrary type?
is there a way to have DatePicker allow user to only choose Sunday/Saturday from
Is there a way to set up CherryPy to use SSL when running behind
Is there a way to have setup/teardown code automagically run before/after each test? Something
Is there a way to have a template specialization based on a range of
Is there a way to have ASP classic cdonts email, have an file attached
Is there a way to have hanging operators when indenting with tabs in Vim?
Is there a way to have rails print out a number with commas in
is there a way to have the cobertura test coverage graph be shown on
Is there any way to have a label wordwrap text as needed? I have

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.