class_docstr: Create a zmq Context
  
  A zmq Context creates sockets via its ``ctx.socket`` method.
  
  .. versionchanged:: 24
  
      When using a Context as a context manager (``with zmq.Context()``),
      or deleting a context without closing it first,
      ``ctx.destroy()`` is called,
      closing any leftover sockets,
      instead of `ctx.term()` which requires sockets to be closed first.
  
      This prevents hangs caused by `ctx.term()` if sockets are left open,
      but means that unclean destruction of contexts
      (with sockets left open) is not safe
      if sockets are managed in other threads.
  
  .. versionadded:: 25
  
      Contexts can now be shadowed by passing another Context.
      This helps in creating an async copy of a sync context or vice versa::
  
          ctx = zmq.Context(async_ctx)
  
      Which previously had to be::
  
          ctx = zmq.Context.shadow(async_ctx.underlying)
class_docstr_tok: ["Create","a","zmq","Context","A","zmq","Context","creates","sockets","via","its","``","ctx.socket","``","method",".","..","versionchanged",":",":","24","When","using","a","Context","as","a","context","manager","(","``","with","zmq.Context","(",")","``",")",",","or","deleting","a","context","without","closing","it","first",",","``","ctx.destroy","(",")","``","is","called",",","closing","any","leftover","sockets",",","instead","of","`","ctx.term","(",")","`","which","requires","sockets","to","be","closed","first",".","This","prevents","hangs","caused","by","`","ctx.term","(",")","`","if","sockets","are","left","open",",","but","means","that","unclean","destruction","of","contexts","(","with","sockets","left","open",")","is","not","safe","if","sockets","are","managed","in","other","threads",".","..","versionadded",":",":","25","Contexts","can","now","be","shadowed","by","passing","another","Context",".","This","helps","in","creating","an","async","copy","of","a","sync","context","or","vice","versa",":",":","ctx","=","zmq.Context","(","async_ctx",")","Which","previously","had","to","be",":",":","ctx","=","zmq.Context.shadow","(","async_ctx.underlying",")"]
docstr: set default sockopts as attributes
docstr_tok: ["set","default","sockopts","as","attributes"]
code: def _set_attr_opt(self, name: str, opt: int, value: OptValT) -> None:
      """set default sockopts as attributes"""
      if name in ContextOption.__members__:
          return self.set(opt, value)
      elif name in SocketOption.__members__:
          self.sockopts[opt] = value
      else:
          raise AttributeError(
              f"No such context or socket option: {name}"
          )
  
imports: import atexit
  import os
  from threading import Lock
  from typing import Any, Callable, Dict, Generic, List, Optional, Type, TypeVar, Union, overload
  from warnings import warn
  from weakref import WeakSet
  from zmq.backend import Context
  from zmq.constants import ContextOption, Errno, SocketOption
  from zmq.error import ZMQError
  from zmq.utils.interop import cast_int_addr
  from .attrsettr import AttributeSetter, OptValT
  from .socket import Socket
label_desc: Use image node_id 21 for calling the Context obj's underlying member method code with example usage: obj._set_attr_opt(name, opt, value) and returns: self