question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More of a question than an issue: Is there a faster way to shutdown and restart when there was a recent connection to the port? For example I just visited this server on it’s port, but now it will take 6 seconds to shutdown:

[01/Dec/2016:13:10:50] ENGINE Console event 0: shutting down bus
[01/Dec/2016:13:10:50] ENGINE Removed handler for console events.
[01/Dec/2016:13:10:50] ENGINE Bus STOPPING
>>>>> 6 seconds later
[01/Dec/2016:13:10:56] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 444)) shut down
[01/Dec/2016:13:10:56] ENGINE Stopped thread 'Autoreloader'.
[01/Dec/2016:13:10:56] ENGINE Stopped thread '_TimeoutMonitor'.
[01/Dec/2016:13:10:56] ENGINE Handler for console events already off.
[01/Dec/2016:13:10:56] ENGINE Bus STOPPED
[01/Dec/2016:13:10:56] ENGINE Bus EXITING
[01/Dec/2016:13:10:56] ENGINE Waiting for child threads to terminate...
[01/Dec/2016:13:10:56] ENGINE Bus EXITED

But if I just start the server, not visit it, and shutdown it’s instant:

[01/Dec/2016:13:25:46] ENGINE Console event 0: shutting down bus
[01/Dec/2016:13:25:46] ENGINE Removed handler for console events.
[01/Dec/2016:13:25:46] ENGINE Bus STOPPING 
[01/Dec/2016:13:25:46] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 444)) shut down
[01/Dec/2016:13:25:46] ENGINE Stopped thread 'Autoreloader'.
[01/Dec/2016:13:25:46] ENGINE Stopped thread '_TimeoutMonitor'.
[01/Dec/2016:13:25:46] ENGINE Handler for console events already off.
[01/Dec/2016:13:25:46] ENGINE Bus STOPPED
[01/Dec/2016:13:25:46] ENGINE Bus EXITING
[01/Dec/2016:13:25:46] ENGINE Waiting for child threads to terminate...
[01/Dec/2016:13:25:46] ENGINE Bus EXITED

I tried to deduct myself where the slowdown is originating, but I got a bit lost in the code…

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
Safihrecommented, Dec 5, 2016

Solved it! The slowdown is in the wsgiserver, which has a timeout of 5 seconds: https://github.com/cherrypy/cherrypy/blob/master/cherrypy/wsgiserver/__init__.py#L1690-L1726

It’s simply overwritten by setting:

cherrypy.config.update({ 'server.shutdown_timeout': 1 })

In case someone else wants to know 👍

0reactions
Candy-Arlincommented, Jun 18, 2020

Hi there guys,

I appreciate this message is quite late on.

I’m sorry but I did not quite follow what you did there @Safihre

My console is stuck at the following line: ENGINE Waiting for thread Thread-6.

How could I implement the above recommendations you made. I tried copying and pasting ‘cherrypy.config.update({ ‘server.shutdown_timeout’: 1 })’ at the start of my script but it didn’t seem to work.

If it helps - Windows 10, P3.7

Also here is the code, taken from: https://www.kdnuggets.com/2020/02/using-fitbit-web-api-python.html

CLIENT_ID=‘REMOVED’ CLIENT_SECRET=‘REMOVED’

cherrypy.config.update({ ‘server.shutdown_timeout’: 1 }) server=Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET) server.browser_authorize() ACCESS_TOKEN=str(server.fitbit.client.session.token[‘access_token’]) REFRESH_TOKEN=str(server.fitbit.client.session.token[‘refresh_token’]) auth2_client=fitbit.fitbit(CLIENT_ID,CLIENT_SECRET,oauth2=True,access_token=ACCESS_TOKEN,refresh_token=REFRESH_TOKEN)

unauth_client = fitbit.Fitbit(‘<consumer_key>’, ‘<consumer_secret>’)

certain methods do not require user keys

unauth_client.food_units()

You’ll have to gather the tokens on your own, or use

./gather_keys_oauth2.py

authd_client = fitbit.Fitbit(‘<consumer_key>’, ‘<consumer_secret>’, access_token=‘<access_token>’, refresh_token=‘<refresh_token>’) authd_client.sleep()

Read more comments on GitHub >

github_iconTop Results From Across the Web

ForceShutdown - Product Documentation
ForceShutdown. Forces a shutdown, power-off or restart when a user logs off from the session. Key. HKLM\Software\RES\Workspace Manager (32-bit) ...
Read more >
5 ways to restart or force shutdown a frozen software or app in ...
5 ways to restart or force shutdown a frozen software or app in Windows · Use Alt+F4 shortcut · Use Command Prompt ·...
Read more >
Force shutdown from a remote system (Windows 10)
Describes the best practices, location, values, policy management, and security considerations for the Force shutdown from a remote system ...
Read more >
Force Shutdown or Restart from Command Line
If you've been using the power button to force shutdown your PC, try this Command Line trick to Force Shutdown and to Force...
Read more >
Force Shutdown - WebLogic Server - Oracle Help Center
Use this RESTful Management Interface to monitor the entire WLS domain.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found