Python论坛  - 讨论区

标题:[python-chinese] Aix 多进操作日志的问题

2007年11月16日 星期五 13:59

Cyril.Liu terry6394在gmail.com
星期五 十一月 16 13:59:04 HKT 2007

我在Aix 5.3 下执行以下代码,用来用来测试多进程下次的日志操作.

#-*-coding: utf-8 -*-

import logging, os, sys, time

def forking_func():
    logging.debug("Here is forking_func")


def main():
    logging.debug("Befor fork: %s" % os.getpid())
    if os.fork():
    time.sleep(10)
        logging.debug("Parent: %s" % os.getpid())
    else:
        logging.debug("child: %s" % os.getpid())
        sys.exit(0)

    print "Exit process my pid: %s " % os.getpid


if __name__ == '__main__':
    main()

结果我得到如下的错误信息:
python test_forking.py
sem_wait: Permission denied
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.4/logging/__init__.py", line 1333, in shutdown
    h.close()
  File "/usr/local/lib/python2.4/logging/__init__.py", line 677, in close
    _releaseLock()
  File "/usr/local/lib/python2.4/logging/__init__.py", line 188, in _releaseLock
    _lock.release()
  File "/usr/local/lib/python2.4/threading.py", line 113, in release
    assert self.__owner is me, "release() of un-acquire()d lock"
AssertionError: release() of un-acquire()d lock
sem_wait: Permission denied
sem_trywait: Permission denied
sem_trywait: Permission denied
sem_post: Permission denied
sem_wait: Permission denied
sem_trywait: Permission denied
sem_post: Permission denied
sem_wait: Permission denied
sem_trywait: Permission denied
sem_post: Permission denied
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/local/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.4/logging/__init__.py", line 1333, in shutdown
    h.close()
  File "/usr/local/lib/python2.4/logging/__init__.py", line 677, in close
    _releaseLock()
  File "/usr/local/lib/python2.4/logging/__init__.py", line 188, in _releaseLock
    _lock.release()
  File "/usr/local/lib/python2.4/threading.py", line 113, in release
    assert self.__owner is me, "release() of un-acquire()d lock"
AssertionError: release() of un-acquire()d lock
sem_trywait: Permission denied
sem_post: Permission denied
sem_destroy: Permission denied
sem_wait: Permission denied
sem_post: Permission denied
sem_wait: Permission denied
sem_post: Permission denied
sem_wait: Permission denied
sem_post: Permission denied
sem_wait: Permission denied
sem_post: Permission denied
Exit process my pid: 409794

看上去似乎是权限的问题。
但是,我用多线程去实现以上的功能是没有问题的。不解。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20071116/bd33a534/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号