1. 创造日志handler: 在status_only模式,不需要日志以及UI

    # Ensure logging messages get sent to the UI as events
handler = bb.event.LogHandler()
if not configParams.status_only:
# In status only mode there are no logs and no UI
logger.addHandler(handler)

2. 取得ui模块并设置特征集:

    if configParams.server_only:
featureset = []
ui_module = None
else:
ui_module = import_extension_module(bb.ui, configParams.ui, 'main')
# Collect the feature set for the UI
featureset = getattr(ui_module, "featureSet", []) if extrafeatures:
for feature in extrafeatures:
if not feature in featureset:
featureset.append(feature)

3. 远程模式下返回远程server连接:

    server_connection = None

    if configParams.remote_server:
# Connect to a remote XMLRPC server
server_connection = bb.server.xmlrpcclient.connectXMLRPC(configParams.remote_server, featureset,
configParams.observe_only, configParams.xmlrpctoken)

4. 本地模式下返回本地server连接:

    else:
retries = 8
while retries:
try:
topdir, lock = lockBitbake()
sockname = topdir + "/bitbake.sock"
if lock:
if configParams.status_only or configParams.kill_server:
logger.info("bitbake server is not running.")
lock.close()
return None, None
# we start a server with a given configuration
logger.info("Starting bitbake server...")
# Clear the event queue since we already displayed messages
bb.event.ui_queue = []
server = bb.server.process.BitBakeServer(lock, sockname, configuration, featureset) else:
logger.info("Reconnecting to bitbake server...")
if not os.path.exists(sockname):
print("Previous bitbake instance shutting down?, waiting to retry...")
i = 0
lock = None
# Wait for 5s or until we can get the lock
while not lock and i < 50:
time.sleep(0.1)
_, lock = lockBitbake()
i += 1
if lock:
bb.utils.unlockfile(lock)
raise bb.server.process.ProcessTimeout("Bitbake still shutting down as socket exists but no lock?")
if not configParams.server_only:
try:
server_connection = bb.server.process.connectProcessServer(sockname, featureset)
except EOFError:
# The server may have been shutting down but not closed the socket yet. If that happened,
# ignore it.
pass if server_connection or configParams.server_only:
break
except BBMainFatal:
raise
except (Exception, bb.server.process.ProcessTimeout) as e:
if not retries:
raise
retries -= 1
if isinstance(e, (bb.server.process.ProcessTimeout, BrokenPipeError)):
logger.info("Retrying server connection...")
else:
logger.info("Retrying server connection... (%s)" % traceback.format_exc())
if not retries:
bb.fatal("Unable to connect to bitbake server, or start one")
if retries < 5:
time.sleep(5)

5. 清理日志handler,返回服务器连接以及ui模块:

    if configParams.kill_server:
server_connection.connection.terminateServer()
server_connection.terminate()
bb.event.ui_queue = []
logger.info("Terminated bitbake server.")
return None, None # Restore the environment in case the UI needs it
for k in cleanedvars:
os.environ[k] = cleanedvars[k] logger.removeHandler(handler) return server_connection, ui_module

yocto-sumo源码解析(六): setup_bitbake的更多相关文章

  1. Celery 源码解析六:Events 的实现

    在 Celery 中,除了远程控制之外,还有一个元素可以让我们对分布式中的任务的状态有所掌控,而且从实际意义上来说,这个元素对 Celery 更为重要,这就是在本文中将要说到的 Event. 在 Ce ...

  2. AFNetworking (3.1.0) 源码解析 <六>

    这次继续介绍文件夹Serialization下的类AFURLResponseSerialization.这次介绍就不拆分了,整体来看一下.h和.m文件. 协议AFURLResponseSerializ ...

  3. ReactiveCocoa源码解析(六) SignalProtocol的take(first)与collect()延展实现

    上篇博客我们聊了observe().map().filter()延展函数的具体实现方式以及使用方式.我们在之前的博客中已经聊过,Signal的主要功能是位于SignalProtocol的协议延展中的, ...

  4. ReactiveSwift源码解析(六) SignalProtocol的take(first)与collect()延展实现

    上篇博客我们聊了observe().map().filter()延展函数的具体实现方式以及使用方式.我们在之前的博客中已经聊过,Signal的主要功能是位于SignalProtocol的协议延展中的, ...

  5. jQuery 源码解析(六) $.each和$.map的区别

    $.each主要是用来遍历数组或对象的,例如: var arr=[11,12,13,14]; $.each(arr,function(element,index){ //遍历arr数组 console ...

  6. QT源码解析(一) QT创建窗口程序、消息循环和WinMain函数

    QT源码解析(一) QT创建窗口程序.消息循环和WinMain函数 分类: QT2009-10-28 13:33 17695人阅读 评论(13) 收藏 举报 qtapplicationwindowse ...

  7. Celery 源码解析三: Task 对象的实现

    Task 的实现在 Celery 中你会发现有两处,一处位于 celery/app/task.py,这是第一个:第二个位于 celery/task/base.py 中,这是第二个.他们之间是有关系的, ...

  8. Celery 源码解析五: 远程控制管理

    今天要聊的话题可能被大家关注得不过,但是对于 Celery 来说确实很有用的功能,曾经我在工作中遇到这类情况,就是我们将所有的任务都放在同一个队列里面,然后有一天突然某个同学的代码写得不对,导致大量的 ...

  9. [源码解析] 并行分布式框架 Celery 之 worker 启动 (1)

    [源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 0x00 摘要 0x01 Celery的架 ...

  10. [源码解析] 并行分布式框架 Celery 之 worker 启动 (2)

    [源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 0x00 摘要 0x01 前文回顾 0x2 ...

随机推荐

  1. 学习python第五天进制转换

    6.进制之间的转换(重要) 二进制:满二进一 范围:0.1符号:0b例如:0b10...[注意]计算机只能识别二进制数据 八进制:满八进一 范围:0~7符号:0o例如:0o66 十进制:满十进一 范围 ...

  2. VS中生成、清理项目、调试、開始运行(不调试)、Debug 和 Release等之间的差别

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/helloUSB2010/article/details/35802437 一.生成和又一次生成 &q ...

  3. repulsion-loss

    行人检测中的mr,fppi这些指标??? 3种距离:欧式距离.SmoothL1距离.IoU距离 总的loss公式:3个部分组成Lattr是预测框和匹配的gt尽可能接近,Lrepgt是预测框和周围没匹配 ...

  4. hive使用derby的服务模式(可以远程模式)

    hive默认使用的derby的嵌入模式.这个就面临着,无法多个并发hive shell共享的问题. 使用MySQL服务器也可以解决问题,但安装.配置太麻烦了. 可以使用轻量级的derby的c/s服务模 ...

  5. Uva514

    https://vjudge.net/problem/UVA-514 #include <bits/stdc++.h> using namespace std; ; int target[ ...

  6. 在ubuntu中添加widows启动项的简单方法

    打开终端执行: sudo vim /boot/grub/grub.cfg 或者 sudo gedit /boot/grub/grub.cfg 打开文件grub.cfg. 在文件中添加:添加的时候注意和 ...

  7. ASP.NET Core下载大文件的实现

    当我们的ASP.NET Core网站需要支持下载大文件时,如果不做控制可能会导致用户在访问下载页面时发生无响应,使得浏览器崩溃.可以参考如下代码来避免这个问题. 关于此代码的几点说明: 将数据分成较小 ...

  8. Windows下修改iTunes备份路径

    0.准备工作: 关闭itunes 在任务管理器中杀掉iTunes开头的服务 1,找到iTunes默认备份路径:C:\Users\xxx\AppData\Roaming\Apple Computer\M ...

  9. #leetcode刷题之路39-组合总和

    给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合.candidates 中的数字可以无限制重复被选取 ...

  10. layedit富文本编辑器获取纯文字内容和全部内容