Python运行注释掉的代码

时间:2016-10-19 00:36:05

标签: python django docker celery

我遇到一个问题,有时docker-py会返回错误:

Permission denied.

我正在努力修复它。我评论了这段代码,并收到了以下图片。

File "/opt/dst/src/utils/runner.py", line 48, in run_code

\#if len(cli.containers(filters={'status': ['running', 'created']})) >= settings.DOCKER_CONTAINER_COUNT:
Traceback (most recent call last):
  File "/opt/dst/env/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/opt/dst/env/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/opt/dst/src/core/tasks.py", line 12, in run
    return 'Solution not found'
  File "/opt/dst/src/utils/runner.py", line 48, in run_code
    #if len(cli.containers(filters={'status': ['running', 'created']})) >= settings.DOCKER_CONTAINER_COUNT:
  File "/opt/dst/env/lib/python2.7/site-packages/docker/api/container.py", line 85, in containers
    res = self._result(self._get(u, params=params), True)
  File "/opt/dst/env/lib/python2.7/site-packages/docker/utils/decorators.py", line 47, in inner
    return f(self, *args, **kwargs)
  File "/opt/dst/env/lib/python2.7/site-packages/docker/client.py", line 132, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/opt/dst/env/lib/python2.7/site-packages/requests/sessions.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "/opt/dst/env/lib/python2.7/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/dst/env/lib/python2.7/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/opt/dst/env/lib/python2.7/site-packages/requests/adapters.py", line 453, in send
    raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

runner.pyc文件已更新。 可能是什么问题呢? 谢谢你的帮助,抱歉我的英文不好

更新:

cli = Client('unix://var/run/docker.sock', version='1.19')
kill_client = Client('unix://var/run/docker.sock', version='1.19', timeout=0.5)
config = cli.create_host_config(**get_host_config(file_path))
#if len(cli.containers(filters={'status': ['running', 'created']})) >= settings.DOCKER_CONTAINER_COUNT:
#    return 'must retry', None
run_string = 'timeout {} python /tmp/script.py'.format(settings.DOCKER_EXECUTE_TIME)
container = cli.create_container('python:2', run_string, user=uid, host_config=config)

1 个答案:

答案 0 :(得分:0)

由于脚本中的错误,使用了两个实例芹菜,并且在使用旧代码的操作实例期间发生了此错误。