Bug 978314 - [RFE] handle stuck RPC calls
[RFE] handle stuck RPC calls
Status: NEW
Product: Fedora
Classification: Fedora
Component: python-nitrate (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Ondrej Hudlicky
Ales Zelinka
: FutureFeature
Depends On:
Blocks: 798710 798713 798718
  Show dependency treegraph
 
Reported: 2013-06-26 06:53 EDT by Ales Zelinka
Modified: 2018-02-14 18:03 EST (History)
2 users (show)

See Also:
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: ---


Attachments (Terms of Use)

  None (edit)
Description Ales Zelinka 2013-06-26 06:53:45 EDT
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 07:16:07 EDT
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."

Note You need to log in before you can comment on or make changes to this bug.