A callback handler for the ControlConnection that tolerates
    weak references.
762884
def _watch_callback(obj_weakref, method_name, *args, **kwargs):
    
    obj = obj_weakref()
    if obj is None:
        return
    getattr(obj, method_name)(*args, **kwargs)
1034401
function ensureConnected(remote, callback) {
  if (remote.getServer()) {
    callback(null, isConnected(remote));
  } else {
    callback(null, false);
  }
}
628403
function (callback) {
            if (!self.commandBumper) {
              return callback(null);
            }
            debug('');

            self.commandBumper.on('connect', function () {
              self.emit('connect');
            });

            self.commandBumper.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.commandBumper.connect(callback);
          }
599699
public void dereferenceControllable()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "dereferenceControllable");
    _remoteDurableName = null;
    _anycastInputHandler = null;
    _destinationHandler = null;
    _messageProcessor = null;
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "dereferenceControllable");    
  }
808779
def _on_trace(_loop, adapter, conn_id, trace):
    """"""

    conn_string = adapter._get_property(conn_id, 'connection_string')
    if conn_string is None:
        adapter._logger.debug("Dropping trace data with unknown conn_id=%s", conn_id)
        return

    adapter.notify_event_nowait(conn_string, 'trace', trace)
1188937
def connectionLost(self, reason):
        
        for wref in self._weakProxies.valuerefs():
            p = wref()
            if p is not None:
                p.connectionLost(reason)
243432
def __handler(self, connection, event):
        
        try:
            # Find local handler
            method = getattr(self, "on_{0}".format(event.type))
        except AttributeError:
            pass
        else:
            try:
                # Call it
                return method(connection, event)
            except Exception as ex:
                logging.exception("Error calling handler: %s", ex)
820546
def _typed_null_handler(c, ctx):
    """"""
    assert c == _DOT
    c, self = yield
    nxt = _NULL_STARTS
    i = 0
    length = None
    done = False
    trans = ctx.immediate_transition(self)
    while True:
        if done:
            if _ends_value(c) or (ctx.container.ion_type is IonType.SEXP and c in _OPERATORS):
                trans = ctx.event_transition(IonEvent, IonEventType.SCALAR, nxt.ion_type, None)
            else:
                _illegal_character(c, ctx, 'Illegal null type.')
        elif length is None:
            if c not in nxt:
                _illegal_character(c, ctx, 'Illegal null type.')
            nxt = nxt[c]
            if isinstance(nxt, _NullSequence):
                length = len(nxt.sequence)
        else:
            if c != nxt[i]:
                _illegal_character(c, ctx, 'Illegal null type.')
            i += 1
            done = i == length
        c, _ = yield trans
1349070
function(connection, probeId, callback) {
      var t = this, proxy = connection.remoteProbesById[probeId];
      if (!proxy) {return callback('Probe not running');}
      if (--proxy.refCount === 0) {
        // Release probe resources
        proxy.release();
        proxy.connection = null;
        delete connection.remoteProbesById[probeId];
        delete connection.remoteProbeIdsByKey[proxy.probeKey];
        connection.removeEvent('probe:change:' + probeId);
        return connection.emit('probe:disconnect', {probeId:probeId}, function(error){
          return callback(error);
        });
      }
      callback(null);
    }
306414
public void dereferenceControllable()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "dereferenceControllable");
    
    super.dereferenceControllable();
    referenceItemStream = null;
    consumerDispatcher = null;
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "dereferenceControllable");
  }
1065531
private void connectIfNotDone(ZMQ.Socket socket, ZMQutils.ControlStructure controlStructure){

        traceZmqSubscription(controlStructure.eventName, true);
        //  Check if not already connected or forced (re connection)
        if (controlStructure.forceReconnection || !alreadyConnected(controlStructure.endPoint)) {
            ApiUtil.printTrace("Set socket buffer for HWM to " + controlStructure.hwm);

            //  Check if it ia a reconnection -> disconnect before connection
            if (controlStructure.forceReconnection && alreadyConnected(controlStructure.endPoint)) {
                try {
                    //  needs an un subscribe before disconnection
                    //socket.unsubscribe(controlStructure.eventName.getBytes());
                    socket.disconnect(controlStructure.endPoint);
                }
                catch (org.zeromq.ZMQException e) {
                    System.err.println(e.getMessage());
                }
            }

            //  Do the connection
            //System.out.println("Connect on " + controlStructure.endPoint);
            //System.out.println("        for " + controlStructure.eventName);
            socket.setHWM(controlStructure.hwm);
            socket.connect(controlStructure.endPoint);
            if (!alreadyConnected(controlStructure.endPoint)) {
                EventList eventList = new EventList();
                eventList.add(controlStructure.eventName);
                connectedMap.put(controlStructure.endPoint, eventList);
            }
            else {
                //  Add to event list if not done
                EventList eventList = connectedMap.get(controlStructure.endPoint);
                String  s = eventList.getEvent(controlStructure.eventName);
                if (s==null)
                    eventList.add(controlStructure.eventName);
            }
        }
        else {
            //  Add to event list if not done
            EventList eventList = connectedMap.get(controlStructure.endPoint);
            String  s = eventList.getEvent(controlStructure.eventName);
            if (s==null)
                eventList.add(controlStructure.eventName);
            ApiUtil.printTrace(
                    ((controlStructure.commandCode==ZMQutils.ZMQ_CONNECT_EVENT)? "Event" : "Heartbeat") +
                    " already connected to " + controlStructure.endPoint);
        }
    }
508786
public void dereferenceControllable()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "dereferenceControllable", tsm);
    
    streamSet = null;
    tsm = null;
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "dereferenceControllable"); 
  }
948317
function (_callback)
    {
        if (_callback) {
            _callback = _callback.bind(this._conn);
        } else {
            _callback = this._conn._connect_cb.bind(this._conn);
        }
        var body = this._buildBody();
        this._requests.push(
                new Strophe.Request(body.tree(),
                    this._onRequestStateChange.bind(
                        this, _callback.bind(this._conn)),
                    body.tree().getAttribute("rid")));
        this._throttledRequestHandler();
    }
546620
public synchronized final void ensureReferencesLoaded() throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "ensureReferencesLoaded");

        _references();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "ensureReferencesLoaded");
    }
948134
function(error) {
        if (error) {
          return callback(error);
        }
        probe.off('change', monitor.probeChange);
        monitor.set({probeId:null});
        monitor.probe = monitor.probeChange = null;
        return callback(null, reason);
      }
400365
public void handleRetry(Throwable cause) {
    try {
      this.retryPolicy.retry(connectionState, retryHandler, connectionFailHandler);
    } catch (RetryPolicy.RetryCancelled retryCancelled) {
      this.getNettyPromise().setFailure(cause);
    }
  }
1198483
function handleDisconnect() {
    _connection = _mysql.createConnection(_dbConfig);

    _connection.connect(function (err) {
        if (err) {
            console.log('error when connecting to db:', err);
            setTimeout(handleDisconnect, 2000);
        }
    });

    _connection.on('error', function (err) {
        console.log('db error', err);
        if (err.code === 'PROTOCOL_CONNECTION_LOST') {
            handleDisconnect();
        } else {
            throw err;
        }
    });
}