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
meloncrashed
V2EX  ›  Python

a.py 调用 b.py, 只是调用不等待 b.py 的运行结束,如何实现?

  •  
  •   meloncrashed · 2015-11-21 13:22:58 +08:00 · 3162 次点击
    这是一个创建于 3072 天前的主题,其中的信息可能已经有所发展或是发生改变。
    7 条回复    2015-11-21 17:15:04 +08:00
    Orzzzz
        1
    Orzzzz  
       2015-11-21 13:40:21 +08:00
    这不就是多进程嘛?
    aborn
        2
    aborn  
       2015-11-21 13:42:27 +08:00
    要是 js 就简单了,就是一个简单的异步调用。
    virusdefender
        3
    virusdefender  
       2015-11-21 13:50:38 +08:00
    celery
    cheneydog
        4
    cheneydog  
       2015-11-21 13:59:40 +08:00   ❤️ 1
    ```python
    #! /usr/bin/env python
    # -*- coding: utf-8 -*-

    import os
    from multiprocessing import Process,freeze_support

    def task():
    os.system('python b.py')


    if __name__ == '__main__':
    freeze_support()
    Process(target=task).start()
    print "i am over"
    ```
    weifengzi2009
        5
    weifengzi2009  
       2015-11-21 14:07:10 +08:00   ❤️ 1
    a 里面调用之后不要 join 就可以了,如果 join 了就是等 b 结束完才继续执行 a
    Valyrian
        6
    Valyrian  
       2015-11-21 14:14:43 +08:00 via iPhone   ❤️ 1
    python 的 os, subprocess, multiprocessing 模块都可以实现
    knightdf
        7
    knightdf  
       2015-11-21 17:15:04 +08:00
    太多方法了。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2590 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 01:37 · PVG 09:37 · LAX 18:37 · JFK 21:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.