Skip to content

Commit 92b97d6

Browse files
authored
Merge pull request #85 from gramaziokohler/set_rosapi_timeout
added set_rosapi_timeout
2 parents 8ef66ab + 665a72a commit 92b97d6

5 files changed

Lines changed: 38 additions & 23 deletions

File tree

CHANGELOG.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Unreleased
1212

1313
**Added**
1414

15+
* Added function to set the default timeout value.
16+
1517
**Changed**
1618

1719
**Fixed**
@@ -29,7 +31,7 @@ Unreleased
2931

3032
**Fixed**
3133

32-
* Fixed blocking issues on the Twisted/Autobahn-based implementation of websockets
34+
* Fixed blocking issues on the Twisted/Autobahn-based implementation of websockets.
3335

3436
**Deprecated**
3537

@@ -61,24 +63,24 @@ Unreleased
6163

6264
**Changed**
6365

64-
* Changed behavior: Topics automatically reconnect when websockets is reconnected
66+
* Changed behavior: Topics automatically reconnect when websockets is reconnected.
6567

6668
**Added**
6769

6870
* Added blocking behavior to more ROS API methods: ``ros.get_nodes`` and ``ros.get_node_details``.
69-
* Added reconnection support to IronPython implementation of websockets
70-
* Added automatic topic reconnection support for both subscribers and publishers
71+
* Added reconnection support to IronPython implementation of websockets.
72+
* Added automatic topic reconnection support for both subscribers and publishers.
7173

7274
**Fixed**
7375

74-
* Fixed reconnection issues on the Twisted/Autobahn-based implementation of websockets
76+
* Fixed reconnection issues on the Twisted/Autobahn-based implementation of websockets.
7577

7678
0.7.1
7779
----------
7880

7981
**Fixed**
8082

81-
* Fixed blocking service calls for Mac OS
83+
* Fixed blocking service calls for Mac OS.
8284

8385
0.7.0
8486
----------
@@ -141,7 +143,7 @@ Unreleased
141143

142144
**Added**
143145

144-
* Add a non-blocking event loop runner
146+
* Add a non-blocking event loop runner.
145147

146148
0.3.0
147149
----------
@@ -155,33 +157,33 @@ Unreleased
155157

156158
**Fixed**
157159

158-
* Fix JSON serialization error on TF Client (on Python 3.x)
160+
* Fix JSON serialization error on TF Client (on Python 3.x).
159161

160162
0.2.0
161163
----------
162164

163165
**Added**
164166

165-
* Add support for IronPython 2.7
167+
* Add support for IronPython 2.7.
166168

167169
**Changed**
168170

169-
* Handler ``on_ready`` now defaults to run the callback in thread
171+
* Handler ``on_ready`` now defaults to run the callback in thread.
170172

171173
**Deprecated**
172174

173-
* Rename ``run_event_loop`` to the more fitting ``run_forever``
175+
* Rename ``run_event_loop`` to the more fitting ``run_forever``.
174176

175177
0.1.1
176178
----------
177179

178180
**Fixed**
179181

180-
* Minimal documentation fixes
182+
* Minimal documentation fixes.
181183

182184
0.1.0
183185
----------
184186

185187
**Added**
186188

187-
* Initial version
189+
* Initial version.

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)