Chunk of Python code continues to run after clicking on red square


I've been running into the problem where I have quite a large chunk of python code hangs up somewhere in the middle. Wanting to abort it, however, doesn't stop the python process (I verified this using the Task Manager).

If I kill the python subprocess from the Task Manager, RStudio just completely hangs up, so that's a problem.

Any ideas, how this issue might be resolved?

I'm using

  • Windows 10
  • Anaconda Python 2 (changed knitr python path using: knitr::opts_chunk$set(engine.path = list(python = '/anaconda/bin/python'))

Can you show this in a reproducible example (reprex)?