Skip to content

Commit 73e79aa

Browse files
HiroIshidajdlangs
authored andcommitted
Add shutdown method for Service object (#75)
* add shutdown method * add doc * add test for shutdown * use preferable pycall style
1 parent 8e06b41 commit 73e79aa

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/services.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#API for calling/creating services. Syntax is practically identical to rospy.
2-
export Service, ServiceProxy, wait_for_service
2+
export Service, ServiceProxy, wait_for_service, shutdown
33

44
"""
55
ServiceProxy{T}(name; kwargs...)
@@ -90,3 +90,11 @@ function wait_for_service(service::AbstractString; kwargs...)
9090
error("Timeout exceeded waiting for service '$service'")
9191
end
9292
end
93+
94+
"""
95+
shutdown(service_obj)
96+
Shut down the specified service.
97+
"""
98+
function shutdown(s::Service{ST}) where ST <: AbstractService
99+
pycall(s.srv_obj.shutdown, Nothing)
100+
end

test/services.jl

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ if flag[1]
5050
end
5151
empty!(msgs)
5252

53+
##Check the service is properly shut down
54+
srv_fake = Service("fake", SetBool, (req)->SetBoolResponse())
55+
@test shutdown(srv_fake) == nothing
56+
5357
#Test error handling
5458
@test_throws ErrorException wait_for_service("fake_srv", timeout=1.0)
5559
@test_throws ArgumentError srvcall(SetBoolResponse())

0 commit comments

Comments
 (0)