class_docstr: A 0MQ Device to be run in the background.
  
  You do not pass Socket instances to this, but rather Socket types::
  
      Device(device_type, in_socket_type, out_socket_type)
  
  For instance::
  
      dev = Device(zmq.QUEUE, zmq.DEALER, zmq.ROUTER)
  
  Similar to zmq.device, but socket types instead of sockets themselves are
  passed, and the sockets are created in the work thread, to avoid issues
  with thread safety. As a result, additional bind_{in|out} and
  connect_{in|out} methods and setsockopt_{in|out} allow users to specify
  connections for the sockets.
  
  Parameters
  ----------
  device_type : int
      The 0MQ Device type
  {in|out}_type : int
      zmq socket types, to be passed later to context.socket(). e.g.
      zmq.PUB, zmq.SUB, zmq.REQ. If out_type is < 0, then in_socket is used
      for both in_socket and out_socket.
  
  Methods
  -------
  bind_{in_out}(iface)
      passthrough for ``{in|out}_socket.bind(iface)``, to be called in the thread
  connect_{in_out}(iface)
      passthrough for ``{in|out}_socket.connect(iface)``, to be called in the
      thread
  setsockopt_{in_out}(opt,value)
      passthrough for ``{in|out}_socket.setsockopt(opt, value)``, to be called in
      the thread
  
  Attributes
  ----------
  daemon : bool
      sets whether the thread should be run as a daemon
      Default is true, because if it is false, the thread will not
      exit unless it is killed
  context_factory : callable (class attribute)
      Function for creating the Context. This will be Context.instance
      in ThreadDevices, and Context in ProcessDevices.  The only reason
      it is not instance() in ProcessDevices is that there may be a stale
      Context instance already initialized, and the forked environment
      should *never* try to use it.
class_docstr_tok: ["A","0MQ","Device","to","be","run","in","the","background",".","You","do","not","pass","Socket","instances","to","this",",","but","rather","Socket","types",":",":","Device","(","device_type",",","in_socket_type",",","out_socket_type",")","For","instance",":",":","dev","=","Device","(","zmq.QUEUE",",","zmq.DEALER",",","zmq.ROUTER",")","Similar","to","zmq.device",",","but","socket","types","instead","of","sockets","themselves","are","passed",",","and","the","sockets","are","created","in","the","work","thread",",","to","avoid","issues","with","thread","safety",".","As","a","result",",","additional","bind_","{","in|out","}","and","connect_","{","in|out","}","methods","and","setsockopt_","{","in|out","}","allow","users","to","specify","connections","for","the","sockets",".","Parameters","--","--","--","--","--","device_type",":","int","The","0MQ","Device","type","{","in|out","}","_type",":","int","zmq","socket","types",",","to","be","passed","later","to","context.socket","(",")",".","e.g",".","zmq.PUB",",","zmq.SUB",",","zmq.REQ",".","If","out_type","is","<","0",",","then","in_socket","is","used","for","both","in_socket","and","out_socket",".","Methods","--","--","--","-","bind_","{","in_out","}","(","iface",")","passthrough","for","``","{","in|out","}","_socket.bind","(","iface",")","``",",","to","be","called","in","the","thread","connect_","{","in_out","}","(","iface",")","passthrough","for","``","{","in|out","}","_socket.connect","(","iface",")","``",",","to","be","called","in","the","thread","setsockopt_","{","in_out","}","(","opt",",","value",")","passthrough","for","``","{","in|out","}","_socket.setsockopt","(","opt",",","value",")","``",",","to","be","called","in","the","thread","Attributes","--","--","--","--","--","daemon",":","bool","sets","whether","the","thread","should","be","run","as","a","daemon","Default","is","true",",","because","if","it","is","false",",","the","thread","will","not","exit","unless","it","is","killed","context_factory",":","callable","(","class","attribute",")","Function","for","creating","the","Context",".","This","will","be","Context.instance","in","ThreadDevices",",","and","Context","in","ProcessDevices",".","The","only","reason","it","is","not","instance","(",")","in","ProcessDevices","is","that","there","may","be","a","stale","Context","instance","already","initialized",",","and","the","forked","environment","should","*","never","*","try","to","use","it","."]
docstr: Cleanup sockets we created
docstr_tok: ["Cleanup","sockets","we","created"]
code: def _close_sockets(self):
      """Cleanup sockets we created"""
      for s in self._sockets:
          if s and not s.closed:
              s.close()
  
imports: import time
  from multiprocessing import Process
  from threading import Thread
  from typing import Any, Callable, List, Optional, Tuple
  import zmq
  from zmq import ENOTSOCK, ETERM, PUSH, QUEUE, Context, ZMQBindError, ZMQError, device
label_desc: Use image node_id 13 for calling the Device obj's underlying member method code with example usage: obj._close_sockets() without return types