提交 65640082 编写于 作者: B barrierye

fix #366: support multi-clients in one process

上级 03ee835e
......@@ -45,7 +45,28 @@ class EndpointRouterBase {
class WeightedRandomRender : public EndpointRouterBase {
public:
static int register_self() {
INLINE_REGIST_OBJECT(WeightedRandomRender, EndpointRouterBase, -1);
// INLINE_REGIST_OBJECT(WeightedRandomRender, EndpointRouterBase, -1);
Factory<WeightedRandomRender, EndpointRouterBase>* factory =
new (std::nothrow) Factory<WeightedRandomRender, EndpointRouterBase>();
if (factory == NULL) {
RAW_LOG_ERROR(
"Failed regist factory: WeightedRandomRender->EndpointRouterBase in "
"macro!");
return -1;
}
// When two clients are created in the same process, two
// "WeightedRandomRender" factory objects are registered.
// But in fact, the two clients can use one factory object
// together.
if (FactoryPool<EndpointRouterBase>::instance().register_factory(
"WeightedRandomRender", factory) != 0) {
RAW_LOG_INFO(
"Factory has been registed: "
"WeightedRandomRender->EndpointRouterBase.");
}
return 0;
}
......
......@@ -156,7 +156,9 @@ class Client(object):
)
else:
if self.predictor_sdk_ is None:
self.add_variant('var1', endpoints, 100)
timestamp = time.time()
self.add_variant('default_tag_{}'.format(timestamp), endpoints,
100)
else:
print(
"parameter endpoints({}) will not take effect, because you use the add_variant function.".
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册