def throw(self, *args):
    if self._ended:
        raise error('Fiber has ended')
    curr = current()
    if (curr._thread_id != self._thread_id):
        raise error('Cannot switch to a fiber on a different thread')
    if (self._cont is None):
        self._ended = True
        return self._get_active_parent().throw(*args)
    try:
        return curr._cont.throw(*args, to=self._cont)
    finally:
        _tls.current_fiber = curr
def throw(self, *args):
    if self._ended:
        raise error('Fiber has ended')
    curr = current()
    if (curr._thread_id != self._thread_id):
        raise error('Cannot switch to a fiber on a different thread')
    if (self._cont is None):
        self._ended = True
        return self._get_active_parent().throw(*args)
    try:
        return curr._cont.throw(*args, to=self._cont)
    finally:
        _tls.current_fiber = curr