def _suspend(self, coro, timeout, alarm_value, state):
        """Internal use only. See sleep/suspend in Coro.
        """
        self._lock.acquire()
        if AsynCoro.__cur_coro != coro:
            self._lock.release()
            logger.warning('invalid "suspend" - "%s" != "%s"', coro, AsynCoro.__cur_coro)
            return -1
        cid = coro._id
        if state == AsynCoro._AwaitMsg_ and coro._msgs:
            s, update = coro._msgs[0]
            if s == state:
                coro._msgs.popleft()
                self._lock.release()
                return update
        if timeout is None:
            coro._timeout = None
        else:
            if not isinstance(timeout, (float, int)):
                logger.warning('invalid timeout %s', timeout)
                self._lock.release()
                return -1
            if timeout <= 0:
                self._lock.release()
                return alarm_value
            else:
                coro._timeout = _time() + timeout
                heappush(self._timeouts, (coro._timeout, cid, alarm_value))
        self._scheduled.discard(cid)
        self._suspended.add(cid)
        coro._state = state
        self._lock.release()
        return 0
dataset/ETHPy150Open pgiri/asyncoro/py2/asyncoro/__init__.py/AsynCoro._suspend/original