Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

The 'environ['werkzeug.server.shutdown']' function is deprecated and will be removed in Werkzeug 2.1. #63

Closed
normansimonr opened this issue May 19, 2021 · 7 comments · Fixed by #80

Comments

@normansimonr
Copy link

Hi. First let me thank you for this amazing library! It's been really useful for me. I just wanted to let you know that I'm getting this warning when using jupyter_dash on Python 3.8. Not sure what it means.

/opt/conda/lib/python3.8/site-packages/jupyter_dash/jupyter_app.py:139: UserWarning:

The 'environ['werkzeug.server.shutdown']' function is deprecated and will be removed in Werkzeug 2.1.

Thanks!

@adigoryl
Copy link

adigoryl commented May 24, 2021

Hi, thank you for your great work! I can relate to the issue above. Since the warning started to appear a couple of days ago, my unchanged and previosly working code, doesn't update the graph layout anymore, giving the following error "Callback error updating graph.figure - Internal server error". @nicolaskruchten do you know more about this warning and do you havea workaround?
Kind regards, Adrian.

@adrien-perello
Copy link

Same problem here. I have a function that create a server and the app. Everything works fine when I call this function in a cell for the first time, but if I want to call it again in another cell, then I get:
The 'environ['werkzeug.server.shutdown']' function is deprecated and will be removed in Werkzeug 2.1.

I understand that it has something to do with flask and the need to shutdown the server. But is there a simple way to manually shutdown the server so I call again the function (without having to restart the jupyter kernel and run only the relevant cells)?

Many thanks, really love to be able to use plotly in Jupyter!! :)

@lachlansimpson
Copy link

From the Werkzeug repo, here is the pull request in question: pallets/werkzeug#1873
And here is the reason for the deprecation: pallets/werkzeug#1752

The reasoning:

This was added in #36 as a way to shutdown local applications, environ["werkzeug.server.shutdown"](). However, the advice
for quite some time has been to use a production server even when running local applications; the development server is 
only for development.

The issue and code comments both describe the implementation as "horrible". The implementation of it is in fact pretty 
weird, having to touch a double underscore "really private" variable, as well as jump through hoops to work with the 
HTTP server loop and handle reloader processes.

Additionally, users see this and then are confused why they can only shut down their application when using the 
development server. Or they want to be able to do more process management such as reloads, which is definitely out of 
scope.

There are a number of proposed solutions in the issue, but smarter minds that me will need to implement.

@RobertJN64
Copy link

RobertJN64 commented Nov 6, 2021

I did some digging into the werkzeug code, and noticed that if you run with make_server instead of flask you can call a server shutdown command. This worked much better for me than the recommended solution of killing processes, which is very janky.

I replaced super_run_server with a custom function based on dash's run server function, but used make_server instead. He is the core part:

if host + ":" + str(port) in activeservers:
    activeservers[host + ":" + str(port)].shutdown()
s = make_server(host, port, dashapp.server, threaded=True)
t = threading.Thread(target=s.serve_forever)
t.start()
activeservers[host + ":" + str(port)] = s

The full code is in my fork: https://github.com/RobertJN64/jupyter-dash/blob/master/jupyter_dash/server_tools.py

If this is an acceptable fix, I can make a pull request.

@aiqc
Copy link
Contributor

aiqc commented Mar 9, 2022

Just ran into this error on a fresh venv when running the tutorial in inline mode:

image

Dependencies

3.7.12 = python
2.2.0 = dash
0.4.1 = jupyter-dash
3.3.0 = jupyterlab
2.0.3 = Werkzeug

It's scary that this hasn't been fixed. I'm trying to determine which front end to bet big on for my largely jupyter-centric app.

T4rk1n added a commit to T4rk1n/jupyter-dash that referenced this issue Mar 10, 2022
T4rk1n added a commit to T4rk1n/jupyter-dash that referenced this issue Mar 10, 2022
T4rk1n added a commit to T4rk1n/jupyter-dash that referenced this issue Mar 18, 2022
T4rk1n added a commit to T4rk1n/jupyter-dash that referenced this issue Mar 30, 2022
@amarnathreddy0201
Copy link

Hi Sir/Mam,

The 'environ['werkzeug.server.shutdown']' function is deprecated and will be removed in Werkzeug 2.1

  1. Then how to close the flask server ?
  2. i am using werkzeug server for shutting down the server
    here is the example : https://stackoverflow.com/questions/15562446/how-to-stop-flask-application-without-using-ctrl-c

3)How to close the flask server without interrupt the other processes.

please suggest me to improve my knowledge.

thanks,
ANR S

@helmutcarter
Copy link

Having the same issue:

    del environ['werkzeug.server.shutdown']
KeyError: 'werkzeug.server.shutdown'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants