Cython, Python and KeyboardInterrupt ignored

前端 未结 4 1970
太阳男子
太阳男子 2020-12-05 11:19

Is there a way to interrupt (Ctrl+C) a Python script based on a loop that is embedded in a Cython extension?

I have the following python script:

4条回答
  •  再見小時候
    2020-12-05 12:18

    Release GIL when Cython runs parts that do not interface with Python, run loop in the main thread (sleep or check the simulation status), and call sim.Stop() (that can set some flag that your simulation can check periodically) in the except close.

提交回复
热议问题