Volttron进入了一个几乎无限循环的循环

时间:2019-08-06 17:14:21

标签: volttron

我已经安装了大约40个代理以进行一些模拟。但是我遇到了一些线程错误。错误如下所示。

  

2019-08-06 10:56:24,120(socialagent-3.0 16231)错误:   线程Thread-31中的异常:2019-08-06 10:56:24,124   (socialagent-3.0 16231)错误:回溯(最近的呼叫   最后):2019-08-06 10:56:24,135(socialagent-3.0 16231)错误:   文件“ /usr/lib/python2.7/threading.py”,第801行,位于   __bootstrap_inner

     

2019-08-06 10:56:24,162(socialagent-3.0 16231)错误:
  self.run()

     

2019-08-06 10:56:24,177(socialagent-3.0 16231)错误:文件   “ /usr/lib/python2.7/threading.py”,第1073行,正在运行

     

2019-08-06 10:56:24,198(socialagent-3.0 16231)错误:
  self.function(* self.args,** self.kwargs)

     

2019-08-06 10:56:24,201(socialagent-3.0 16231)错误:文件   “ /home/jenny/.volttron/agents/50b42ee5-b6af-4a25-aa89-97e2b1a823e1/socialagent-3.0/social/agent.py”,   第145行,位于enter_phase3

     

2019-08-06 10:56:24,240(socialagent-3.0 16231)错误:
  self.vip.pubsub.publish('pubsub',ids_topic,message = message)

     

2019-08-06 10:56:24,265(socialagent-3.0 16231)错误:文件   “ /home/jenny/workspace/volttron/volttron/platform/vip/agent/subsystems/pubsub.py”,   第607行,在发布中

     

2019-08-06 10:56:24,267(socialagent-3.0 16231)错误:
  self.vip_socket.send_vip(b'','pubsub',框架,result.ident,   copy = False)

     

2019-08-06 10:56:24,279(socialagent-3.0 16231)错误:文件   “ /home/jenny/workspace/volttron/volttron/platform/vip/socket.py”,行   404,在send_vip中

     

2019-08-06 10:56:24,326(socialagent-3.0 16231)错误:
  将self._sending(flags)作为标志:

     

2019-08-06 10:56:24,327(socialagent-3.0 16231)错误:文件   __enter __

中的“ /usr/lib/python2.7/contextlib.py”,第17行      

2019-08-06 10:56:24,377(socialagent-3.0 16231)错误:
  返回self.gen.next()

     

2019-08-06 10:56:24,402(socialagent-3.0 16231)错误:文件   “ /home/jenny/workspace/volttron/volttron/platform/vip/green.py”,行   78,在_sending

     

2019-08-06 10:56:24,413(socialagent-3.0 16231)错误:
  而不是lock.acquire(不是标志&NOBLOCK):

     

2019-08-06 10:56:24,422(socialagent-3.0 16231)错误:文件   “ /home/jenny/workspace/volttron/env/local/lib/python2.7/site-packages/gevent/lock.py”,   获取中的第210行

     

2019-08-06 10:56:24,427(socialagent-3.0 16231)错误:rc   = self._block.acquire(blocking)

     

2019-08-06 10:56:24,442(socialagent-3.0 16231)错误:文件   “ gevent / _semaphore.py”,第198行,在   gevent._semaphore.Semaphore.acquire(gevent / gevent._semaphore.c:4117)

     

2019-08-06 10:56:24,451(socialagent-3.0 16231)错误:
  def获得(自我,阻止=真实,超时=无):

     

2019-08-06 10:56:24,485(socialagent-3.0 16231)错误:文件   “ gevent / _semaphore.py”,第226行,在   gevent._semaphore.Semaphore.acquire(gevent / gevent._semaphore.c:3944)

     

2019-08-06 10:56:24,493(socialagent-3.0 16231)错误:
  超时= self._do_wait(超时)

     

2019-08-06 10:56:24,503(socialagent-3.0 16231)错误:文件   “ gevent / _semaphore.py”,第166行,在   gevent._semaphore.Semaphore._do_wait(gevent / gevent._semaphore.c:3178)

     

2019-08-06 10:56:24,546(socialagent-3.0 16231)错误:
  结果= get_hub()。switch()

     

2019-08-06 10:56:24,552(socialagent-3.0 16231)错误:文件   “ /home/jenny/workspace/volttron/env/local/lib/python2.7/site-packages/gevent/hub.py”,   开关中的609行

     

2019-08-06 10:56:24,574(socialagent-3.0 16231)错误:
  返回greenlet.switch(self)

     

2019-08-06 10:56:24,589(socialagent-3.0 16231)错误:   LoopExit :(“此操作将永远阻止”,

     

2019-08-06 10:56:24,640(socialagent-3.0 16231)错误:

这就是我在agent.py文件的第145行上显示的内容: self.vip.pubsub.publish('pubsub', ds_topic, message=message) 我已经将一条消息定义为message =“ something”

当我安装更少的代理程序时,我根本不会遇到这个问题。我正在运行1.9GHz英特尔酷睿i3机器;这可能相关吗?为了提供尽可能多的信息以帮助诊断问题,我在此处显示了一些代理的摘要:

from threading import Timer

@Core.receiver("onstart")
def starting(self, sender, **kwargs):
    _log.debug('Subscribing to all relevant topics')
    self.vip.pubsub.subscribe('pubsub', pred_topic, callback=self.from_pred)  


def from_pred(self, peer, sender, bus, topic, headers, message):          
    message_dict = message_parser.mess_conv(message)
    message = "{}: {}".format(statID, message_dict['feat_pro'])
    # Publish to all neighbour topics and to our own topic
    for k in neighbours:
        self.vip.pubsub.publish('pubsub', k, message=message)
    self.vip.pubsub.publish('pubsub', social_topic, message=message)
    # ...and start timer to allow communication for 8s
    timer = Timer(8, self.enter_phase)
    timer.start()

def enter_phase(self):
    # Send a message to IDS to begin phase 
    _log.debug("In agent {}. We have {}".format(stationID, sent_prob))
    if stationID in sent_prob.keys():
        message = "phase3: 1"
    else:
        message = "phase3: 0"
    self.vip.pubsub.publish('pubsub', ds_topic, message=message)

此外,timer = Timer(8, self.enter_phase)可能是问题的一部分吗?我不是一个开发专家,将不胜感激(用简单的语言:))。

1 个答案:

答案 0 :(得分:0)

这可能是由于猴子补丁问题引起的。 VOLTTRON平台代码使用gevent修补的套接字和未修补的线程。

您的代理是执行monkey.patchall()还是导入了执行gevent monkey.patchall()的模块?您的代理是否依赖需要未修补Socket的软件包/其他库?如果您的代理需要未打补丁的Socket模块,则可以在代码中导入Socket语句后重新加载(套接字)。 VOLTTRON为mongo historian(请参阅volttron / platform / dbutils / mongoutils.py)执行此操作,因为pymongo库需要取消修补套接字和线程模块。