Skip to content

Commit 5dbfd16

Browse files
committed
added set_rosapi_timeout
1 parent 8ef66ab commit 5dbfd16

4 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/roslibpy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
3737
.. autoclass:: Ros
3838
:members:
39+
.. autofunction:: set_rosapi_timeout
3940
4041
Main ROS concepts
4142
=================
@@ -106,6 +107,7 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
106107
from .core import Time
107108
from .core import Topic
108109
from .ros import Ros
110+
from .ros import set_rosapi_timeout
109111

110-
__all__ = ['Ros', 'Message', 'Header', 'Time', 'Param', 'Service', 'ServiceRequest', 'ServiceResponse', 'Topic', '__author__',
112+
__all__ = ['Ros', 'set_rosapi_timeout', 'Message', 'Header', 'Time', 'Param', 'Service', 'ServiceRequest', 'ServiceResponse', 'Topic',
111113
'__author__', '__author_email__', '__copyright__', '__description__', '__license__', '__title__', '__url__', '__version__']

src/roslibpy/comm/comm_autobahn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def blocking_call_from_thread(self, callback, timeout):
206206
207207
Args:
208208
callback: Callable function to be invoked from the thread.
209-
timeout (:obj: int): Number of seconds to wait for the response before
209+
timeout (:obj:`int`): Number of seconds to wait for the response before
210210
raising an exception.
211211
212212
Returns:
@@ -233,7 +233,7 @@ def get_inner_callback(self, result_placeholder):
233233
"""Get the callback which, when called, provides result_placeholder with the result.
234234
235235
Args:
236-
result_placeholder: (:obj: Deferred): Object in which to store the result.
236+
result_placeholder: (:class:`Deferred`): Object in which to store the result.
237237
238238
Returns:
239239
A callable which provides result_placeholder with the result in the case of success.
@@ -246,7 +246,7 @@ def get_inner_errback(self, result_placeholder):
246246
"""Get the errback which, when called, provides result_placeholder with the error.
247247
248248
Args:
249-
result_placeholder: (:obj: Deferred): Object in which to store the result.
249+
result_placeholder: (:class:`Deferred`): Object in which to store the result.
250250
251251
Returns:
252252
A callable which provides result_placeholder with the error in the case of failure.

src/roslibpy/comm/comm_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def blocking_call_from_thread(self, callback, timeout):
456456
457457
Args:
458458
callback: Callable function to be invoked from the thread.
459-
timeout (:obj: int): Number of seconds to wait for the response before
459+
timeout (:obj:`int`): Number of seconds to wait for the response before
460460
raising an exception.
461461
462462
Returns:
@@ -493,7 +493,7 @@ def get_inner_callback(self, result_placeholder):
493493
"""Get the callback which, when called, provides result_placeholder with the result.
494494
495495
Args:
496-
result_placeholder: (:obj: dict): Object in which to store the result.
496+
result_placeholder: (:obj:`dict`): Object in which to store the result.
497497
498498
Returns:
499499
A callable which provides result_placeholder with the result in the case of success.
@@ -507,7 +507,7 @@ def get_inner_errback(self, result_placeholder):
507507
"""Get the errback which, when called, provides result_placeholder with the error.
508508
509509
Args:
510-
result_placeholder: (:obj: dict): Object in which to store the result.
510+
result_placeholder: (:obj:`dict`): Object in which to store the result.
511511
512512
Returns:
513513
A callable which provides result_placeholder with the error in the case of failure.

src/roslibpy/ros.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
from . import Time
1111
from .comm import RosBridgeClientFactory
1212

13-
__all__ = ['Ros']
13+
__all__ = ['Ros', 'set_rosapi_timeout']
1414

1515
LOGGER = logging.getLogger('roslibpy')
1616
CONNECTION_TIMEOUT = 10
1717
ROSAPI_TIMEOUT = 3
1818

1919

20+
def set_rosapi_timeout(timeout):
21+
"""Set the default number of seconds to wait for a response before
22+
raising an exception.
23+
24+
Args:
25+
timeout (:obj:`int`): Duration in seconds.
26+
"""
27+
global ROSAPI_TIMEOUT
28+
ROSAPI_TIMEOUT = timeout
29+
30+
2031
class Ros(object):
2132
"""Connection manager to ROS server.
2233
@@ -194,7 +205,7 @@ def blocking_call_from_thread(self, callback, timeout):
194205
195206
Args:
196207
callback: Callable function to be invoked from the thread.
197-
timeout (:obj: int): Number of seconds to wait for the response before
208+
timeout (:obj:`int`): Number of seconds to wait for the response before
198209
raising an exception.
199210
200211
Returns:
@@ -231,7 +242,7 @@ def call_sync_service(self, message, timeout):
231242
232243
Args:
233244
message (:class:`.Message`): ROS Bridge Message containing the request.
234-
timeout (:obj: int): Number of seconds to wait for the response before
245+
timeout (:obj:`int`): Number of seconds to wait for the response before
235246
raising an exception.
236247
Returns:
237248
Either returns the service request results or raises a timeout exception.

0 commit comments

Comments
 (0)