1

I'm invoking git as a shell command, and want to timeout after X amount of seconds and terminate the operation.

I've considered multiprocessing.Process, since it has join() with a timeout and terminate(). However, I'd prefer using a thread for a couple of reasons:

  • It's more lightweight
  • The code invoking the git is already running in a multiprocessing.Process with daemon=True, and so cannot spawn child processes itself (except if I change daemon=False, but then the parent of the spawning process won't its child).

How can I run the git command in a thread using a timeout, and terminate the thread if the timeout has elapsed?

Shuzheng
  • 11,288
  • 20
  • 88
  • 186

0 Answers0