0

I have code like this:

from multiprocessing import Process

proc = Process(target=some_blocking_callable)
proc.start()
time.sleep(1)
proc.terminate()

It works well, but it seems the termination (by SIGTERM) causes an error message and stack trace to be printed to stderr:

*** Aborted at 1611012345 (unix time) try "date -d @1611012345" if you are using GNU date ***
*** SIGTERM (@0x1beb001cd21c) received by PID 2814123 (TID 0x7fefa035b740) from PID 2814123; stack trace: ***
<very long stack trace>

Is there a way to completely suppress this error, and/or all stderr/stdout output from proc?

Goh
  • 167
  • 5
  • https://stackoverflow.com/a/6735958/1032785 – jordanm Jan 19 '21 at 17:09
  • @jordanm this is a solution to suppress **all** stderr. I only want to suppress `proc` stderr. – Goh Jan 19 '21 at 17:12
  • 1
    Execute one of those examples first thing inside of `some_blocking_callable`, or even better have `some_block_callable` catch the exception caused by the sigterm. – jordanm Jan 19 '21 at 17:16
  • @jordanm Handling SIGTERM worked, though it can't be caught as an exception. Just handled as a signal. Submit this as an answer if you like. – Goh Jan 19 '21 at 20:20

0 Answers0