V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yakczh
V2EX  ›  Python

apr_socket_connect(): 以一种访问权限不允许的方式做了一个访问套接字的尝试

  •  
  •   yakczh · 2013-11-30 22:19:29 +08:00 · 3232 次点击
    这是一个创建于 3815 天前的主题,其中的信息可能已经有所发展或是发生改变。
    windows下用fastcgi跑php,因为没有php-fpm 所以用python写了个监控程序,监视php-cgi.exe的个数,如果少于10个,就用subprocess.Popen重新生成一个 



    import os
    import subprocess
    import time
    import thread
    def timer(no, interval):
    cnt = 0
    while cnt < 100:
    print ' %d Thread:(%d) Time:%s\n' % (cnt,no, time.ctime())
    check()
    time.sleep(interval)
    print cnt
    cnt=cnt+1
    thread.exit_thread()

    def test(): #Use thread.start_new_thread() to create 2 new threads
    t=thread.start_new_thread(timer, (1,1))

    #thread.start_new_thread(timer, (2,2))


    def check():

    cmd="php-cgi.exe -c php.ini -b 127.0.0.1:9000"

    pipe = os.popen("tasklist |grep php-cgi.exe")

    cgi_cnt = len(pipe.read().split("\n"))

    pipe.close()
    print(cgi_cnt)
    if cgi_cnt < 10:
    out=subprocess.Popen(cmd,shell=True)
    print(out)

    if __name__=='__main__':
    test()
    while True:
    pass


    用浏览器访问可以,但是用ab一测试,就会提示apr_socket_connect(): 以一种访问权限不允许的方式做了一个访问套接字的尝试,这是什么原因?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2657 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:59 · PVG 12:59 · LAX 21:59 · JFK 00:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.