run.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:guillotina 作者: plone 项目源码 文件源码
def run(self, arguments, settings, app):
        aiotask_context.set('request', self.request)
        script = os.path.abspath(arguments.script)
        spec = importlib.util.spec_from_file_location("module.name", script)
        module = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)
        if not hasattr(module, 'run'):
            logger.warn(f'Not `async def run()` function found in file {script}')
            return
        sig = inspect.signature(module.run)
        if 'container' in sig.parameters:
            async for txn, tm, container in get_containers(self.request):
                await module.run(container)
                await tm.commit(txn=txn)
        else:
            await lazy_apply(module.run, app)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号