From 32568dc879410ca12e17e36dcd450fa7223c2282 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 15 Aug 2016 03:18:24 +0200 Subject: [PATCH] Start only one worker with the nothreading option. (#298) Reuse the nothreading option of the runserver command to only start one worker. --- channels/management/commands/runserver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/channels/management/commands/runserver.py b/channels/management/commands/runserver.py index be9b643..45debb1 100644 --- a/channels/management/commands/runserver.py +++ b/channels/management/commands/runserver.py @@ -65,7 +65,8 @@ class Command(RunserverCommand): # Launch workers as subthreads if options.get("run_worker", True): - for _ in range(4): + worker_count = 4 if options.get("use_threading", True) else 1 + for _ in range(worker_count): worker = WorkerThread(self.channel_layer, self.logger) worker.daemon = True worker.start()