Allowing Ctrl-C to interrupt a python C-extension

后端 未结 4 448
情歌与酒
情歌与酒 2020-12-10 03:20

I\'m running some computationally heavy simulation in (home-made) C-based python extensions. Occasionally I get stuff wrong and would like to terminate a simulation. However

4条回答
  •  粉色の甜心
    2020-12-10 04:18

    I would redesign the C extensions so that they don't run for a long period.

    So, split them into more elementary steps (each running for a short period of time, e.g. 10 to 50 milliseconds), and have these more elementary steps called by Python code.

    continuation passing style might be relevant to understand, as a programming style...

提交回复
热议问题