Reset proxy object and notify close event listener

 === Parameters
 thread_name(String):: execution thread name or default

 === Return
 true:: Always return true
4058
def close(thread_name)
      close_callback = @close_callbacks[thread_name]
      close_callback.call if close_callback
      true
    ensure
      @auditors[thread_name] = nil
      @close_callbacks[thread_name] = nil
    end
745129
def close_thread(self):
		
		if self.__thread is not None and self.__thread.is_alive() is True:
			raise WThreadJoiningTimeoutError('Thread is still alive. Thread name: %s' % self.__thread.name)
		self.start_event().clear()
		self.__thread = None
708458
def _thread_error(self, thread):
        

        # Avoid double-killing the thread
        if thread == self._send_thread:
            self._send_thread = None
        if thread == self._recv_thread:
            self._recv_thread = None

        # Figure out why the thread exited
        if thread.successful():
            exception = socket.error('thread exited prematurely')
        elif isinstance(thread.exception, gevent.GreenletExit):
            # Thread was killed; don't do anything but close
            self.close()
            return
        else:
            exception = thread.exception

        # Close the connection...
        self.close()

        # Notify the application what happened
        self.closed(exception)
885521
def stop_dispatch_thread!(timeout=2)
    logger.debug { "#{self.class}##{__method__}" }

    if @dispatcher
      if @dispatcher.join(0)
        @dispatcher = nil
        return
      end

      @mutex.synchronize do
        event_queue.graceful_close!

        # we now release the mutex so that dispatch_next_callback can grab it
        # to do what it needs to do while delivering events
        #
        @dispatch_shutdown_cond.wait

        # wait for another timeout sec for the thread to join
        until @dispatcher.join(timeout)
          logger.error { "Dispatch thread did not join cleanly, waiting" }
        end
        @dispatcher = nil
      end
    end
  end
210738
def proxy_reconnect(proxy_name, opts=None):
    '''
    
    '''

    if not opts:
        opts = __opts__

    if 'proxy' not in opts:
        return False  # fail

    proxy_keepalive_fn = proxy_name+'.alive'
    if proxy_keepalive_fn not in __proxy__:
        return False  # fail

    is_alive = __proxy__[proxy_keepalive_fn](opts)
    if not is_alive:
        minion_id = opts.get('proxyid', '') or opts.get('id', '')
        log.info('%s (%s proxy) is down. Restarting.', minion_id, proxy_name)
        __proxy__[proxy_name+'.shutdown'](opts)  # safely close connection
        __proxy__[proxy_name+'.init'](opts)  # reopen connection
        log.debug('Restarted %s (%s proxy)!', minion_id, proxy_name)

    return True
964746
def getThread(self, name):
		
		if not name in self.thread_list:
			self.logger.error("Thread {0} is not registered!".format(name))
			raise Exception("Thread {0} is not registered!".format(name))

		return self.thread_list[name]
622968
def update_native_thread_name
      thread = JRuby.reference(Thread.current)
      set_thread_name = Proc.new do |prefix, suffix|
        self.class.with_global_lock do
          count = self.class.system_registered_workers.size
          thread.native_thread.name = "#{prefix}##{count}#{suffix}"
        end
      end
      if ! name = thread.native_thread.name
        # "#{THREAD_ID}##{count}" :
        set_thread_name.call(WORKER_THREAD_ID, nil)
      elsif ! name.index(WORKER_THREAD_ID)
        # "#{name}(#{THREAD_ID}##{count})" :
        set_thread_name.call("#{name} (#{WORKER_THREAD_ID}", ')')
      end
    end
1323087
def _reset_on_error(self, server, func, *args, **kwargs):
        
        try:
            return func(*args, **kwargs)
        except NetworkTimeout:
            # The socket has been closed. Don't reset the server.
            raise
        except ConnectionFailure:
            self.__reset_server(server.description.address)
            raise
1007059
def get_lock (name, debug=False):
    
    lock = threading.Lock()
    # for thread debugging, use the DebugLock wrapper
    if debug:
        lock = DebugLock(lock, name)
    return lock
1348786
def set_thread(self, thread = None):
        
        if thread is None:
            self.__thread = None
        else:
            self.__load_Thread_class()
            if not isinstance(thread, Thread):
                msg  = "Parent thread must be a Thread instance, "
                msg += "got %s instead" % type(thread)
                raise TypeError(msg)
            self.dwThreadId = thread.get_tid()
            self.__thread = thread
1240748
def bind(self):
        
        log.debug("Set SO_REUSADDR")
        self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
        
        # we want daemon threads, so we join on abrupt shutdown (applies if multithreaded) 
        self.daemon_threads = True

        self.server_bind()
        self.server_activate()
192662
def patch_thread(threading=True, _threading_local=True, Queue=True, Event=False):
    
    monkey.patch_module('thread')
    if threading:
        monkey.patch_module('threading')
        threading = __import__('threading')
        if Event:
            from gevent.event import Event
            threading.Event = Event
        if Queue:
            from gevent import queue
            threading.queue = queue
    if _threading_local:
        _threading_local = __import__('_threading_local')
        from gevent.local import local
        _threading_local.local = local
940467
def _pop_async_request(self, msg_id, msg_name):
        
        assert get_thread_ident() == self.ioloop_thread_id
        if msg_id is None:
            msg_id = self._msg_id_for_name(msg_name)
        if msg_id in self._async_queue:
            callback_tuple = self._async_queue[msg_id]
            del self._async_queue[msg_id]
            self._async_id_stack[callback_tuple[0].name].remove(msg_id)
            return callback_tuple
        else:
            return None, None, None, None, None
937368
def thread_global(name, default_value = nil)
      is_a?(Module) or raise TypeError, "receiver has to be a Module"

      name = name.to_s
      var_name = "@__#{name}_#{__id__.abs}__"

      lock = Mutex.new
      modul = self

      define_method(name) do
        lock.synchronize { modul.instance_variable_get var_name }
      end

      define_method(name + "=") do |value|
        lock.synchronize { modul.instance_variable_set var_name, value }
      end

      modul.instance_variable_set var_name, default_value if default_value
      self
    end
1021308
def thread_local_property(name):
    ''''''
    name = '_thread_local_' + name

    def fget(self):
        try:
            return getattr(self, name).value
        except AttributeError:
            return None

    def fset(self, value):
        getattr(self, name).value = value

    return property(fget=fget, fset=fset)
941339
def do_trace(self, arg):
        
        if arg:     # XXX this check is to be removed
            raise CmdError("too many arguments")
        if self.lastEvent is None:
            raise CmdError("no current thread set")
        self.lastEvent.get_thread().set_tf()
        return True
1184969
def lock(self, fail_on_lock=False, cleanup=False):
        
        return self.connection.lock(self, fail_on_lock, cleanup)