Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
activity.logger.error(msg)
else:
print msg
finally:
qiapp.stop()
qi.async(activity.on_start).addCallback(handle_on_start_done)
# Run the QiApplication, which runs until someone calls qiapp.stop()
qiapp.run()
finally:
# Cleanup
if hasattr(activity, "on_stop"):
# We need a qi.async call so that if the class is single threaded,
# it will wait for callbacks to be finished.
qi.async(activity.on_stop).wait()
if service_id:
qiapp.session.unregisterService(service_id)
service_id = qiapp.session.registerService(service_name, activity)
if hasattr(activity, "on_start"):
def handle_on_start_done(on_start_future):
"Custom callback, for checking errors"
if on_start_future.hasError():
try:
msg = "Error in on_start(), stopping application: %s" \
% on_start_future.error()
if hasattr(activity, "logger"):
activity.logger.error(msg)
else:
print msg
finally:
qiapp.stop()
qi.async(activity.on_start).addCallback(handle_on_start_done)
# Run the QiApplication, which runs until someone calls qiapp.stop()
qiapp.run()
finally:
# Cleanup
if hasattr(activity, "on_stop"):
# We need a qi.async call so that if the class is single threaded,
# it will wait for callbacks to be finished.
qi.async(activity.on_stop).wait()
if service_id:
qiapp.session.unregisterService(service_id)
@qi.bind()
def disconnectSubscribers(self):
""" disconnect all subscribers from callbacks """
qi.info(self.serviceName, "DISCONNECTING SUBSCRIBERS")
if self.subscribeToggle:
for event in self.subscribers.keys():
future = qi.async(self.disconnectSubscriber, event, delay = 0)
future.wait(1000) # add a timeout to avoid deadlock
if not future.isFinished():
qi.error(self.serviceName, "disconnectSubscribers", "Failed disconnecting %s subscribers" % event)
self.subscribeToggle = False
def __init__(self, time_in_secs):
FutureWrapper.__init__(self)
time_in_microseconds = int(MICROSECONDS_PER_SECOND * time_in_secs)
self.fut = qi.async(self.set_finished, delay=time_in_microseconds)