2 from threading 
import Lock
 
   17     def __init__(self, service_name, service_type, protocol):
 
   43             "args": message_conversion.extract_values(req)
 
   48         while request_id 
not in self.
responses.keys():
 
   60                     "Service %s was unadvertised with a service call in progress, " 
   61                     "aborting service call with request ID %s" % (self.
service_name, request_id))
 
   70         Signal the AdvertisedServiceHandler to shutdown 
   72         Using this, rather than just rospy.Service.shutdown(), allows us 
   73         time to stop any active service requests, ending their busy wait 
   78         start_time = time.time()
 
   79         while time.time() - start_time < timeout:
 
   85     advertise_service_msg_fields = [(
True, 
"service", string_types), (
True, 
"type", string_types)]
 
   89         Capability.__init__(self, protocol)
 
   99         service_name = message[
"service"]
 
  101         if AdvertiseService.services_glob 
is not None and AdvertiseService.services_glob:
 
  102             self.
protocol.log(
"debug", 
"Service security glob enabled, checking service: " + service_name)
 
  104             for glob 
in AdvertiseService.services_glob:
 
  105                 if (fnmatch.fnmatch(service_name, glob)):
 
  106                     self.
protocol.log(
"debug", 
"Found match with glob " + glob + 
", continuing service advertisement...")
 
  110                 self.
protocol.log(
"warn", 
"No match found for service, cancelling service advertisement for: " + service_name)
 
  113             self.
protocol.log(
"debug", 
"No service security glob, not checking service advertisement.")
 
  116         if service_name 
in self.
protocol.external_service_list.keys():
 
  117             self.
protocol.log(
"warn", 
"Duplicate service advertised. Overwriting %s." % service_name)
 
  118             self.
protocol.external_service_list[service_name].service_handle.shutdown(
"Duplicate advertiser.")
 
  119             del self.
protocol.external_service_list[service_name]
 
  122         service_type = message[
"type"]
 
  124         self.
protocol.external_service_list[service_name] = service_handler
 
  125         self.
protocol.log(
"info", 
"Advertised service %s." % service_name)