code: def term_context(ctx, timeout):
      """Terminate a context with a timeout"""
      t = Thread(target=ctx.term)
      t.daemon = True
      t.start()
      t.join(timeout=timeout)
      if t.is_alive():
          # reset Context.instance, so the failure to term doesn't corrupt subsequent tests
          zmq.sugar.context.Context._instance = None
          raise RuntimeError(
              "context could not terminate, open sockets likely remain in test"
          )
  
imports: import os
  import platform
  import signal
  import sys
  import time
  import warnings
  from functools import partial
  from threading import Thread
  from typing import List
  from unittest import SkipTest, TestCase
  from pytest import mark
  import zmq
  from zmq.utils import jsonapi
label_desc: Use image node_id 1 for calling a global function with example usage: term_context(ctx, timeout) without return types