Bug 978314 - [RFE] handle stuck RPC calls
Summary: [RFE] handle stuck RPC calls
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: python-nitrate
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Ondrej Hudlicky
QA Contact: Ales Zelinka
URL:
Whiteboard:
Depends On:
Blocks: 798710 798713 798718
TreeView+ depends on / blocked
 
Reported: 2013-06-26 10:53 UTC by Ales Zelinka
Modified: 2018-02-14 23:03 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

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."


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