Bug 978314

Summary: [RFE] handle stuck RPC calls
Product: [Fedora] Fedora Reporter: Ales Zelinka <azelinka>
Component: python-nitrateAssignee: Ondrej Hudlicky <ohudlick>
Status: NEW --- QA Contact: Ales Zelinka <azelinka>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: ohudlick, psklenar
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 798710, 798713, 798718    

Description Ales Zelinka 2013-06-26 10:53:45 UTC
sometimg a rpc call to nitrate gets stuck and there's (AFAIK) no way how to handle this cleanly. Would it be possible to implement e.g. a built-in timeout to the update function or some way of resetting & recycling a stuck connection?

Comment 1 Petr Šplíchal 2013-06-26 11:16:07 UTC
Yes, that should be relatively easy to implement. We just have to
figure out what would the best place where to handle the timeouts,
especially with the fresh support for multicall (still needs some
polishing).

Pasting Brano's implementation brainstorming for future reference:

#!/usr/bin/python

import sys
import signal
import nitrate

class TimeoutException(Exception):
    pass

def get_it(timeout):
    def timeout_handler(signum, frame):
        raise TimeoutException()

    old_handler = signal.signal(signal.SIGALRM, timeout_handler)
    signal.alarm(timeout)

    tc = nitrate.TestCase(76191)
    tc.notes = "jdfgdfglfdjgkldfjgldfjglfdjgldfjgljdfgbndjfbnvdfvfdvfdv"

    try:
        tc.update()
        return True
    except TimeoutException:
        return False
    finally:
        signal.signal(signal.SIGALRM, old_handler)

    signal.alarm(0)
    return name

if __name__ == '__main__':
    try:
        print str(get_it(1))
    except TimeoutException:
        print "Timeout."

    try:
        print str(get_it(5))
    except TimeoutException:
        print "Timeout."