未验证 提交 ba3ffda1 编写于 作者: D Dong Daxiang 提交者: GitHub

Merge pull request #395 from barrierye/multi-clients-in-one-process

support multi-clients in one process
...@@ -45,7 +45,28 @@ class EndpointRouterBase { ...@@ -45,7 +45,28 @@ class EndpointRouterBase {
class WeightedRandomRender : public EndpointRouterBase { class WeightedRandomRender : public EndpointRouterBase {
public: public:
static int register_self() { 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; return 0;
} }
......
...@@ -156,7 +156,9 @@ class Client(object): ...@@ -156,7 +156,9 @@ class Client(object):
) )
else: else:
if self.predictor_sdk_ is None: 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: else:
print( print(
"parameter endpoints({}) will not take effect, because you use the add_variant function.". "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.
先完成此消息的编辑!
想要评论请 注册