Beispiel #1
0
 def handle(self, *args, **options):
     # Get the backend to use
     self.verbosity = options.get("verbosity", 1)
     self.logger = setup_logger('django.channels', self.verbosity)
     self.channel_layer = channel_layers[options.get("layer", DEFAULT_CHANNEL_LAYER)]
     # Check that handler isn't inmemory
     if self.channel_layer.local_only():
         raise CommandError(
             "You cannot span multiple processes with the in-memory layer. " +
             "Change your settings to use a cross-process channel layer."
         )
     # Check a handler is registered for http reqs
     # Serve static files if Django in debug mode
     if settings.DEBUG:
         self.channel_layer.router.check_default(http_consumer=StaticFilesConsumer())
     else:
         self.channel_layer.router.check_default()
     # Launch a worker
     self.logger.info("Running worker against channel layer %s", self.channel_layer)
     # Optionally provide an output callback
     callback = None
     if self.verbosity > 1:
         callback = self.consumer_called
     # Run the worker
     try:
         worker = Worker(
             channel_layer=self.channel_layer,
             callback=callback,
             only_channels=options.get("only_channels", None),
             exclude_channels=options.get("exclude_channels", None),
         )
         worker_ready.send(sender=worker)
         worker.run()
     except KeyboardInterrupt:
         pass
 def run(self):
     self.logger.debug("Worker thread running")
     worker = Worker(channel_layer=self.channel_layer,
                     signal_handlers=False)
     worker.ready()
     worker.run()
     self.logger.debug("Worker thread exited")
Beispiel #3
0
 def handle(self, *args, **options):
     # Get the backend to use
     self.verbosity = options.get("verbosity", 1)
     # Get the channel layer they asked for (or see if one isn't configured)
     if "layer" in options:
         self.channel_layer = get_channel_layer(options["layer"])
     else:
         self.channel_layer = get_channel_layer()
     if self.channel_layer is None:
         raise CommandError(
             "You do not have any CHANNEL_LAYERS configured.")
     # Run the worker
     self.logger = setup_logger("django.channels", self.verbosity)
     self.logger.info("Running worker for channels %s", options["channels"])
     worker = Worker(
         application=get_default_application(),
         channels=options["channels"],
         channel_layer=self.channel_layer,
     )
     worker.run()
Beispiel #4
0
 def handle(self, *args, **options):
     # Get the backend to use
     self.verbosity = options.get("verbosity", 1)
     self.logger = setup_logger('django.channels', self.verbosity)
     self.channel_layer = channel_layers[options.get(
         "layer", DEFAULT_CHANNEL_LAYER)]
     # Check that handler isn't inmemory
     if self.channel_layer.local_only():
         raise CommandError(
             "You cannot span multiple processes with the in-memory layer. "
             + "Change your settings to use a cross-process channel layer.")
     # Check a handler is registered for http reqs
     # Serve static files if Django in debug mode
     if settings.DEBUG:
         self.channel_layer.router.check_default(
             http_consumer=StaticFilesConsumer())
     else:
         self.channel_layer.router.check_default()
     # Launch a worker
     self.logger.info("Running worker against channel layer %s",
                      self.channel_layer)
     # Optionally provide an output callback
     callback = None
     if self.verbosity > 1:
         callback = self.consumer_called
     # Run the worker
     try:
         worker = Worker(
             channel_layer=self.channel_layer,
             callback=callback,
             only_channels=options.get("only_channels", None),
             exclude_channels=options.get("exclude_channels", None),
         )
         worker_ready.send(sender=worker)
         worker.run()
     except KeyboardInterrupt:
         pass
Beispiel #5
0
 def run(self):
     self.logger.debug("Worker thread running")
     worker = Worker(channel_layer=self.channel_layer, signal_handlers=False)
     worker.ready()
     worker.run()
     self.logger.debug("Worker thread exited")
Beispiel #6
0
 def run(self):
     self.logger.debug("Worker thread running")
     worker = Worker(channel_layer=self.channel_layer)
     worker.run()
     self.logger.debug("Worker thread exited")
Beispiel #7
0
 def run(self):
     worker = Worker(channel_layer=self.channel_layer,
                     signal_handlers=False)
     worker.ready()
     worker.run()
Beispiel #8
0
 def run(self):
     self.logger.debug("Worker thread running")
     worker = Worker(channel_layer=self.channel_layer)
     worker.run()
     self.logger.debug("Worker thread exited")