当前位置: 首页>>代码示例>>Python>>正文


Python autoreload.run_with_reloader方法代码示例

本文整理汇总了Python中django.utils.autoreload.run_with_reloader方法的典型用法代码示例。如果您正苦于以下问题:Python autoreload.run_with_reloader方法的具体用法?Python autoreload.run_with_reloader怎么用?Python autoreload.run_with_reloader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.autoreload的用法示例。


在下文中一共展示了autoreload.run_with_reloader方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def handle(self, *args, **options):
        self.stdout.write("Starting celery worker with autoreload...")
        autoreload.run_with_reloader(restart_celery, args=None, kwargs=None) 
开发者ID:fceruti,项目名称:django-starter-project,代码行数:5,代码来源:celery_autoreload.py

示例2: handle

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def handle(self, *args, **options):
        options_schema = options.get("schema")

        if options_schema and type(options_schema) is str:
            module_str, schema_name = options_schema.rsplit(".", 1)
            mod = importlib.import_module(module_str)
            schema = getattr(mod, schema_name)

        elif options_schema:
            schema = options_schema

        else:
            schema = graphene_settings.SCHEMA

        out = options.get("out") or graphene_settings.SCHEMA_OUTPUT

        if not schema:
            raise CommandError(
                "Specify schema on GRAPHENE.SCHEMA setting or by using --schema"
            )

        indent = options.get("indent")
        watch = options.get("watch")
        if watch:
            autoreload.run_with_reloader(
                functools.partial(self.get_schema, schema, out, indent)
            )
        else:
            self.get_schema(schema, out, indent) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:31,代码来源:graphql_schema.py

示例3: handle

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def handle(self, *args, **options):
        print('Starting celery worker with autoreload...')
        autoreload.run_with_reloader(restart_celery) 
开发者ID:palfrey,项目名称:wharf,代码行数:5,代码来源:celery.py

示例4: handle

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def handle(self, *args, **options):
        if options['autoreload'] is True:
            self.stdout.write("ATTENTION! Autoreload is enabled!")
            if hasattr(autoreload, "run_with_reloader"):
                # Django 2.2. and above
                autoreload.run_with_reloader(self._serve, **options)
            else:
                # Before Django 2.2.
                autoreload.main(self._serve, None, options)
        else:
            self._serve(**options) 
开发者ID:gluk-w,项目名称:django-grpc,代码行数:13,代码来源:grpcserver.py

示例5: test_swallows_keyboard_interrupt

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def test_swallows_keyboard_interrupt(self, mocked_get_reloader):
        mocked_get_reloader.side_effect = KeyboardInterrupt()
        autoreload.run_with_reloader(lambda: None)  # No exception 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_autoreload.py

示例6: test_calls_sys_exit

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def test_calls_sys_exit(self, mocked_restart_reloader):
        mocked_restart_reloader.return_value = 1
        with self.assertRaises(SystemExit) as exc:
            autoreload.run_with_reloader(lambda: None)
        self.assertEqual(exc.exception.code, 1) 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_autoreload.py

示例7: test_calls_start_django

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def test_calls_start_django(self, mocked_reloader, mocked_start_django):
        mocked_reloader.return_value = mock.sentinel.RELOADER
        autoreload.run_with_reloader(mock.sentinel.METHOD)
        self.assertEqual(mocked_start_django.call_count, 1)
        self.assertSequenceEqual(
            mocked_start_django.call_args[0],
            [mock.sentinel.RELOADER, mock.sentinel.METHOD]
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:test_autoreload.py

示例8: handle

# 需要导入模块: from django.utils import autoreload [as 别名]
# 或者: from django.utils.autoreload import run_with_reloader [as 别名]
def handle(self, *args: Any, **options: Any) -> None:
        logging.basicConfig()
        logger = logging.getLogger('process_queue')

        def exit_with_three(signal: int, frame: FrameType) -> None:
            """
            This process is watched by Django's autoreload, so exiting
            with status code 3 will cause this process to restart.
            """
            logger.warning("SIGUSR1 received. Restarting this queue processor.")
            sys.exit(3)

        if not settings.USING_RABBITMQ:
            # Make the warning silent when running the tests
            if settings.TEST_SUITE:
                logger.info("Not using RabbitMQ queue workers in the test suite.")
            else:
                logger.error("Cannot run a queue processor when USING_RABBITMQ is False!")
            raise CommandError

        def run_threaded_workers(queues: List[str], logger: logging.Logger) -> None:
            cnt = 0
            for queue_name in queues:
                if not settings.DEVELOPMENT:
                    logger.info('launching queue worker thread ' + queue_name)
                cnt += 1
                td = Threaded_worker(queue_name)
                td.start()
            assert len(queues) == cnt
            logger.info('%d queue worker threads were launched', cnt)

        if options['all']:
            signal.signal(signal.SIGUSR1, exit_with_three)
            autoreload.run_with_reloader(run_threaded_workers, get_active_worker_queues(), logger)
        elif options['multi_threaded']:
            signal.signal(signal.SIGUSR1, exit_with_three)
            queues = options['multi_threaded']
            autoreload.run_with_reloader(run_threaded_workers, queues, logger)
        else:
            queue_name = options['queue_name']
            worker_num = options['worker_num']

            logger.info("Worker %d connecting to queue %s", worker_num, queue_name)
            worker = get_worker(queue_name)
            worker.setup()

            def signal_handler(signal: int, frame: FrameType) -> None:
                logger.info("Worker %d disconnecting from queue %s", worker_num, queue_name)
                worker.stop()
                sys.exit(0)
            signal.signal(signal.SIGTERM, signal_handler)
            signal.signal(signal.SIGINT, signal_handler)
            signal.signal(signal.SIGUSR1, signal_handler)

            worker.start() 
开发者ID:zulip,项目名称:zulip,代码行数:57,代码来源:process_queue.py


注:本文中的django.utils.autoreload.run_with_reloader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。