log.debug("%s is currently in state: %s" % (self, self.instance.state))
# Launch in a separate thread
- return await asyncio.to_thread(callback)
+ await asyncio.to_thread(callback)
+
+ async def start(self):
+ """
+ Starts the instance on AWS
+ """
+ await asyncio.to_thread(self._start)
+
+ def _start(self):
+ log.info("Starting %s" % self)
+
+ # Send the start signal
+ self.instance.start()
+
+ log.debug("Waiting until %s has started" % self)
+
+ # And wait until the instance is running
+ self.instance.wait_until_running()
+
+ log.debug("%s has been started" % self)
+
+ async def stop(self):
+ """
+ Stops this instance on AWS
+ """
+ await asyncio.to_thread(self._stop)
+
+ def _stop(self):
+ log.info("Stopping %s" % self)
+
+ # Send the stop signal
+ self.instance.stop()
+
+ log.debug("Waiting until %s has stopped" % self)
+
+ # And wait until the instance has been stopped
+ self.instance.wait_until_stopped()
+
+ log.debug("%s has been stopped" % self)
def generate_password_hash(password, salt=None, algo="sha512"):