Python - Can't kill main thread with KeyboardInterrupt

前端 未结 2 1025
礼貌的吻别
礼貌的吻别 2020-12-17 17:26

I\'m making a simple multi-threaded port scanner. It scans all ports on host and returns open ports. The trouble is interrupting the scan. It take a lot of time for a scan t

2条回答
  •  余生分开走
    2020-12-17 17:42

    When you create the threads add them to a list of running threads and when dealing with ctrl-C send a kill signal to each thread on the list. That way you are actively cleaning up rather than relying on it being done for you.

提交回复
热议问题