0

When I try to run mkdocs serve as a subprocess and use CTRL+C to quit the MkDocs server, the parent Python process quits instantly, too. Not even finally clauses or functions registered with atexit are called.

try:
  os.system('mkdocs serve')
finally:
  print('>> finally')

What the heck is going on? I can't find anything suspicious after looking at the implementation of the mkdocs serve command. Tested with Python 3.4 on Windows.


Update: Turns out this seems to be an issue with Mintty (GitForWindows) on Windows. Everything works fine if I run the Python script from Cmder or the native Windows command prompt..

Niklas R
  • 16,299
  • 28
  • 108
  • 203
  • Mm, does the same happen if you run `cat`, or another program? Is the `KeyboardInterrupt` exception reaching your script? – salezica Dec 28 '16 at 15:02
  • It doesn't seem to be the `KeyboardInterrupt`, if it was I would be able to catch it and the finally-clause should be executed. It works fine with `cat`. :) – Niklas R Dec 28 '16 at 15:06
  • Wait, I'm confused, I could swear it just worked. :') Apparently it doesn't work with `cat`... So maybe it is a keyboard interrupt that is not raised as a KeyboardInterrupt exception by Python? – Niklas R Dec 28 '16 at 15:14
  • @slezica Just added an update to the question, it appears to be an issue with Mintty. – Niklas R Dec 28 '16 at 15:23

0 Answers0