小编Rad*_*ads的帖子

Python中的"无法启动新的线程错误"

我正在运行一个脚本,它从debian包中提取信息并将其保存在数据库中.

从大约100个包中提取信息后发生错误.错误是"无法启动新线程"为什么我会遇到此错误?可能的解决办法是什么?

这是用于保存数据的代码:

for i in list_pack:

      if not i in oblist:        
        #Creating Packages
            slu=slugify(i)
            ob=Gbobject()
            ob.title=i
            ob.slug=slu
            ob.content=''
            ob.tags=tagname
        #with reversion.create_revision():
            ob.save()
            gb=Gbobject.objects.get(title=i)
            gb.objecttypes.add(Objecttype.objects.get(title='Packages'))
            gb.sites.add(Site.objects.get_current())
        #with reversion.create_revision():
            gb.save()
            gd=Gbobject.objects.get(title=i)
            print 'The Object created was',gd


            #Decsription
            try:
                atv=package_description_dict[i]
                atvalue=unicode(atv,'utf-8')
            except UnicodeDecodeError:
                pass
            try:
                lo=Gbobject.objects.get(title=i)
                loid=NID.objects.get(id=lo.id)
            except Gbobject.DoesNotExist:
                pass
            if atvalue<>'':
                slu=slugify(atvalue)
                at=Attribute()
                at.title=atvalue
                at.slug=slu
                at.svalue=atvalue
                at.subject=loid
                att=Attributetype.objects.get(title='Description')
                at.attributetype=att
                #with reversion.create_revision():
                at.save()                    
                print 'yeloow13'
Run Code Online (Sandbox Code Playgroud)

就像Description,有大约2个属性的包,以类似的方式保存.

这是发生错误时获得的完整回溯: -

    error                                     Traceback (most recent call last)

/home/radhika/Desktop/dev_75/gnowsys-studio/demo/<ipython console> in <module>()

/usr/local/lib/python2.6/dist-packages/django_gstudio-0.3.dev-py2.6.egg/gstudio/Harvest/debdata.py in …
Run Code Online (Sandbox Code Playgroud)

python multithreading python-multithreading

4
推荐指数
1
解决办法
2万
查看次数