推荐学习书目
› 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
hellowords
V2EX  ›  Python

问一个关于 django 的问题。

  •  
  •   hellowords · Oct 24, 2017 · 2343 views
    This topic created in 3267 days ago, the information mentioned may be changed or developed.
    如下这是我写的方法。如何让用户想开启就开启?想关闭就会自动关闭所有正在执行的操作。

    def monitor(request,url,enable=True):
    if enable:
    '''
    执行 monitor 监控,创建一个线程来执行监控函数。。不停的监控。
    '''
    return HttpResponse("开启完成")
    else:
    '''
    这里需要结束上面还在执行的线程该如果操作?
    '''
    return HttpResponse("关闭完成")
    1 replies  •  2017-10-24 14:09:06 +08:00
    smgui
        1
    smgui  
       Oct 24, 2017
    数据库或者 cache 里给任务做标记,线程执行的过程中读取标记。
    如果标记为“关闭任务”则线程退出。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:29 · PVG 06:29 · LAX 15:29 · JFK 18:29
    ♥ Do have faith in what you're doing.