Skip to content

Commit

Permalink
Added option to force REST Flask app to run single-threaded to avoid …
Browse files Browse the repository at this point in the history
…GPU deadlocks
  • Loading branch information
taavi-primer authored and seldondev committed Apr 30, 2020
1 parent a161969 commit a0af358
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions python/seldon_core/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ def main():
default=int(os.environ.get("GUNICORN_MAX_REQUESTS_JITTER", "0")),
help="Maximum random jitter to add to max-requests.",
)
parser.add_argument(
"--single-threaded",
type=int,
default=int(os.environ.get("FLASK_SINGLE_THREADED", "0")),
help="Force the Flask app to run single-threaded",
)

args = parser.parse_args()

Expand Down Expand Up @@ -322,7 +328,7 @@ def rest_prediction_server():
)
StandaloneApplication(app, user_object, options=options).run()

logger.info("REST gunicorn microservice running on port %i", port)
logger.info("REST microservice running on port %i", port)
server1_func = rest_prediction_server

else:
Expand All @@ -342,9 +348,13 @@ def rest_prediction_server():
logger.info("Set JAEGER_EXTRA_TAGS %s", jaeger_extra_tags)
tracing = FlaskTracing(tracer, True, app, jaeger_extra_tags)

app.run(host="0.0.0.0", port=port)
app.run(host="0.0.0.0", port=port, threaded=False if args.single_threaded else True)

logger.info("REST microservice running on port %i", port)
logger.info(
"REST gunicorn microservice running on port %i single-threaded=%s",
port,
args.single_threaded
)
server1_func = rest_prediction_server

elif args.api_type == "GRPC":
Expand Down

0 comments on commit a0af358

Please sign in to comment.