Python多线程问题 请大虾们帮忙看看~~谢谢了? 400 报错
| 我用的平台是PythonWin,版本是3.3。 当输入t = Mythread(2) 生成Mythread对象时,就出错了,现在还没有头绪,望指教! >>> import threading >>> import time >>> class Mythread(threading.Thread): ... def init(self,id): ... threading.Thread.init(self) ... self.id = id ... def run(self): ... x = 0 ... time.sleep(60) ... print (self.id) ... >>> def func(): ... t.start() ... for i in range(5): ... print (i) ... >>> t = Mythread(2) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "E:\Program Files (x86)\Python33\lib\threading.py", line 536, in init assert group is None, "group argument must be None for now" AssertionError: group argument must be None for now >>> File "<interactive input>", line 1, in <module> File "E:\Program Files (x86)\Python33\lib\threading.py", line 536, in init assert group is None, "group argument must be None for now" AssertionError: group argument must be None for now |
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
class Thread:
__initialized = False
# Need to store a reference to sys.exc_info for printing
# out exceptions when a thread tries to use a global var. during interp.
# shutdown and thus raises an exception about trying to perform some
# operation on/with a NoneType
__exc_info = _sys.exc_info
# Keep sys.exc_clear too to clear the exception just before
# allowing .join() to return.
#XXX __exc_clear = _sys.exc_clear
def __init__(self, group=None, target=None, name=None,args=(), kwargs=None, *, daemon=None):
assert group is None, "group argument must be None for now"
if kwargs is None:
kwargs = {}
self._target = target
self._name = str(name or _newname())
self._args = args
self._kwargs = kwargs
if daemon is not None:
self._daemonic = daemon
else:
self._daemonic = current_thread().daemon
self._ident = None
self._started = Event()
self._stopped = False
self._block = Condition(Lock())
self._initialized = True
# sys.stderr is not stored in the class like
# sys.exc_info since it can be changed between instances
self._stderr = _sys.stderr
_dangling.add(self)######
试试 t=Mythread(None)