Add slight delay when stopping the metadata API

This commit is contained in:
Joshua Boniface 2019-12-18 11:56:04 -05:00
parent 39c9f911cc
commit 364ab10673
1 changed files with 3 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import gevent.pywsgi
import flask import flask
import threading import threading
import sys import sys
import time
import psycopg2 import psycopg2
from psycopg2.extras import RealDictCursor from psycopg2.extras import RealDictCursor
@ -112,7 +113,9 @@ class MetadataAPIInstance(object):
self.logger.out('Stopping Metadata API at 169.254.169.254:80', state='i') self.logger.out('Stopping Metadata API at 169.254.169.254:80', state='i')
try: try:
self.md_http_server.stop() self.md_http_server.stop()
time.sleep(0.1)
self.md_http_server.close() self.md_http_server.close()
time.sleep(0.1)
self.md_http_server = None self.md_http_server = None
self.logger.out('Successfully stopped Metadata API', state='o') self.logger.out('Successfully stopped Metadata API', state='o')
except Exception as e: except Exception as e: