Here if the process times out, it is not terminated (https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate).
Something like
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, encoding='utf-8')
try:
stdout, stderr = p.communicate(example.source, timeout=10)
except subprocess.TimeoutExpired:
p.kill()
stdout, stderr = p.communicate()
could fix it.
Here if the process times out, it is not terminated (https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate).
Something like
could fix it.