client must wait until service callback finish?
As title, I have the following two python codes,
#!/usr/bin/env python
from __future__ import print_function
import sys
import rospy
from test_srv.srv import *
def client_send(x, y):
rospy.wait_for_service('test_server')
try:
t1 = rospy.get_time()
c = rospy.ServiceProxy('test_server', test)
c(x, y)
print("Run Time: ", (rospy.get_time() - t1))
except rospy.ServiceException as e:
print("Service call failed: %s"%e)
def do_something():
print("Doing something...")
if __name__ == "__main__":
rospy.init_node('test_server_node_1')
x = 10
y = 11
print("Client: Start sending.")
client_send(x, y)
do_something()
and
#!/usr/bin/env python
from __future__ import print_function
from time import sleep
from test_srv.srv import test, testResponse
import rospy
def handleCB(req):
print("start sleep")
sleep(3)
print("Get request: %s and %s" %(req.a, req.b))
return testResponse()
def test_server():
rospy.init_node('test_server_node')
s = rospy.Service('test_server',test, handleCB)
print("Ready.")
rospy.spin()
if __name__ == "__main__":
test_server()
the srv file:
int64 a
int64 b
---
When running these codes, the client will keep waiting until server finishes its handleCB
function.
My question is that can client send request and then do other things, not just wait for the server sending response back?
Thanks.
Update:
running result: see image