| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| reply = 'y' | ||
| self.message('') | ||
| if reply == 'y' or reply == '': | ||
| os._exit(0) |
There was a problem hiding this comment.
I think I'd prefer sys.exit here. os._exit may lead to unreleased resources. If the user wants to kill the process faster, they can hit Ctrl-C or Ctrl-\ after.
Sorry, something went wrong.
There was a problem hiding this comment.
It's always possible to have unreleased resources - we can't prevent that with SystemExit. It may get better in some cases, but raising SystemExit in an arbitrary place of the code does not seem like a very safe way to end the program to me. The only way to make sure all resources are released (if the program is written correctly) is to continue the program.
One of the problem of SystemExit is:
while True:
try:
breakpoint()
except:
passThis will trap in debugger forever. I know this example is a bit artificial, but it's not that rare for programs to handle SystemExit, and it's frustrating for users to be stuck in the debugger when they just want to quit.
We have a warning for the users already and they should be aware that they are "killing" a process - which means the resources could potentially be leaked. At least they'll know the process will definitely be killed after they say yes.
Of course that's my thought, and is open to more discussion.
Sorry, something went wrong.
|
I'm having second thought about this. Not because of the resource release, but it seems like some people will bring up pdb in REPL, for example by running some code with breakpoint() in it. Force quit will kill REPL as well. So maybe SystemExit would be a better choice and it kind of provides a similar backwards compatibility to BdbQuit. |
Sorry, something went wrong.
|
Well, obviously sys.exit(0) will kill REPL as well, maybe that's ok. I'm switching to sys.exit(0) now. |
Sorry, something went wrong.
|
@iritkatriel any suggestions on this feature? Thanks! |
Sorry, something went wrong.
IPython, at least, catches SystemExit and tells you that your program tried to quit. So sys.exit() is better than os._exit() there. |
Sorry, something went wrong.
|
Hey @iritkatriel , any suggestions on this PR? I'm just circling back to my unmerged PRs :) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
There are a few design details, which are open to discuss:
In rare cases, where a separate non-daemon thread is there or the code in a raw try ... except ... block, force exit would do well for a debugger.