[Solved] Python3 / subprocess.check_output / Timeout does not work for every command

Freude Asks: Python3 / subprocess.check_output / Timeout does not work for every command
I’m running Debian 10.8 with Python 3.7.3 and running a subprocess inside a script which I would like to interrupt after some seconds. This works for cmd_1 but not for cmd_2 in the example below (timeout is never triggered):

import subprocess
import os, sys

# collect proxies and verify
    # cmd_1 = "while true; do sleep 1; done"
    cmd_2 = "proxybroker find --types HTTPS -l 1000 --outfile proxybroker.txt"
    timeout_sec = 3
    subprocess.check_output(cmd_2, shell=True, timeout=timeout_sec)
except Exception as e:

If I run cmd_2 in a bash, it works fine. I did install the proxybroker package with pip3 install proxybroker.

On another system running Ubuntu 21.04 the timeout works for both commands. Thanks if someone can provide a hint.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.