Git Product home page Git Product logo

Comments (4)

davidism avatar davidism commented on June 2, 2024

Why can't you catch SystemExit?

from werkzeug.

david672orford avatar david672orford commented on June 2, 2024

I can and did once in finally figured out why I could not catch the exception. My concern is that the behavior is surprising, undocumented, and difficult to diagnose. Unless you know that SystemExit specificially is the exception being raised, your attempts to catch it will likely fail. In the interests of not frustrating users of Werkzeug it would be better to replace:

sys.exit(1)

With:

raise

If this is undesirable for some reasons, this unusual behavior of run_simple() should at least be documented. And that brings us to another problem. While run_simple() is described in the tutorial, I can't find it anywhere in the reference section. Maybe I'm missing it, but I can't find it even with the search function.

from werkzeug.

davidism avatar davidism commented on June 2, 2024

The development server isn't really intended for embedding. You can, but it's not particularly secure (nor is http.server which it wraps). Both have strong warnings about this in their docs, and the dev server shows a warning when started as well. The development server is intended for local development only. You should use a production server, such as Waitress, when embedding. For local development, the fact that the server exits when it can't connect seems fine.

from werkzeug.

david672orford avatar david672orford commented on June 2, 2024

OK. As you say, there is a workaround, even if it is obscure. I was feeling pretty frustrated when I wrote this bug report. And since the primary application is testing, the error message is adequate and many users would consider a stack trace worse.

I still do think though that run_simple() and other public interfaces in werkzeug.serving should be included in the reference documentation.

from werkzeug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.