Revision 0d1e78dd

b/lib/build/rpc_definitions.py
37 37
"""
38 38

  
39 39

  
40
# Various time constants for the timeout table
40
# Guidelines for choosing timeouts:
41
# - call used during watcher: timeout of 1min, _TMO_URGENT
42
# - trivial (but be sure it is trivial) (e.g. reading a file): 5min, _TMO_FAST
43
# - other calls: 15 min, _TMO_NORMAL
44
# - special calls (instance add, etc.): either _TMO_SLOW (1h) or huge timeouts
41 45
TMO_URGENT = 60 # one minute
42 46
TMO_FAST = 5 * 60 # five minutes
43 47
TMO_NORMAL = 15 * 60 # 15 minutes
b/lib/rpc.py
71 71
_TMO_4HRS = 4 * 3600
72 72
_TMO_1DAY = 86400
73 73

  
74
# Timeout table that will be built later by decorators
75
# Guidelines for choosing timeouts:
76
# - call used during watcher: timeout -> 1min, _TMO_URGENT
77
# - trivial (but be sure it is trivial) (e.g. reading a file): 5min, _TMO_FAST
78
# - other calls: 15 min, _TMO_NORMAL
79
# - special calls (instance add, etc.): either _TMO_SLOW (1h) or huge timeouts
80

  
81
_TIMEOUTS = {
82
}
83

  
84 74
#: Special value to describe an offline host
85 75
_OFFLINE = object()
86 76

  
......
127 117
  curl.setopt(pycurl.CONNECTTIMEOUT, _RPC_CONNECT_TIMEOUT)
128 118

  
129 119

  
130
def _RpcTimeout(secs):
131
  """Timeout decorator.
132

  
133
  When applied to a rpc call_* function, it updates the global timeout
134
  table with the given function/timeout.
135

  
136
  """
137
  def decorator(f):
138
    name = f.__name__
139
    assert name.startswith("call_")
140
    _TIMEOUTS[name[len("call_"):]] = secs
141
    return f
142
  return decorator
143

  
144

  
145 120
def RunWithRPC(fn):
146 121
  """RPC-wrapper decorator.
147 122

  
......
420 395
    @param read_timeout: Read timeout for request
421 396

  
422 397
    """
423
    if read_timeout is None:
424
      read_timeout = _TIMEOUTS.get(procedure, None)
425

  
426 398
    assert read_timeout is not None, \
427 399
      "Missing RPC read timeout for procedure '%s'" % procedure
428 400

  

Also available in: Unified diff