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

Python 的 pp 模块 提示变量未定义错误

  •  
  •   linuxchild · 2017-09-23 15:12:02 +08:00 · 2085 次点击
    这是一个创建于 2379 天前的主题,其中的信息可能已经有所发展或是发生改变。

    啊,实际上这个主题是因为这个问题

    现在想使用 pp 模块试一下,代码如下:

    cpu_num = 8
        job_server = pp.Server(cpu_num)
        a =  []
        for f in file_lists:
            a.append(job_server.submit(func_name, (f, ), (fun_1, func_2, ), ('sys', 'datetime', 'pp')))
        for x in a:
            tmp = x()
    

    提示的错误如下:

    An error has occured during the function execution
    Traceback (most recent call last):
      File "/usr/lib/python2.6/site-packages/ppworker.py", line 90, in run
        __result = __f(*__args)
      File "<string>", line 2, in decrypt_file
    NameError: global name 'xxx' is not defined
    

    这个 xxx 变量是我在文件开头定义的一个变量,确定已经定义了… 哪位用过这个,对这个比较熟悉

    第 1 条附言  ·  2017-09-23 20:49:14 +08:00
    唔,把那些变量在函数里重新定义就好了……还没深究其原因
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2891 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:20 · PVG 22:20 · LAX 07:20 · JFK 10:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.