内核(用户Python环境)已终止,错误代码为-11

时间:2016-05-07 17:10:39

标签: python canopy

我使用线程来创建模块和以下错误消息。我不知道以下代码到底出了什么问题。谁能给我一些线索?

错误讯息: 内核(用户Python环境)已终止,错误代码为-11。这可能是由于您的代码或内核本身存在错误。 如果您使用的是前Jupyter Canopy并且尚未更新" ipython"在Canopy包管理器中打包,请立即执行,然后重新启动内核。



    class Counter:
        def __init__(self):
            self.lock=threading.Lock() #define a lock attribute
            self.value=0               #define a value attribute

        def increment(self):
            self.lock.acquire() #acquire the global lock
            self.value=self.value+1 #the value variable can only be accessed by one thread
            self.lock.release() #release the lock
            return self.value

        def v(self):
            return self.value
    c=Counter() #define a global counter variable

    class SelectedStockList:
        def __init__(self):
            self.lock=threading.Lock()
            self.value=[]

        def add_item(self,item):
            self.lock.acquire()
            self.value.append(item)
            self.lock.release()
            return self.value

        def get_value(self):
            return self.value
    selectedStockList=SelectedStockList() #define a list to store the stock

    class Worker(threading.Thread):
        """ Thread worker for selecting stocks in input list"""
        def __init__(self,StockList):
            threading.Thread.__init__(self)
            self.StockList=StockList

        def run(self):
            #global c
            global selectedStockList
            for i in self.StockList:
                print "Threadname=", self.getName()
                print "Active Threads=", threading.active_count()
                result=SelectStockRule(i)
                #c.increment()
                #print "Counter=", c.v()
                print "Result=", result
                if result != False:
                    selectedStockList.add_item(str(result))
                print "selectedStockList=", selectedStockList.get_value()
                print "............................................................"
                time.sleep(0.1)

    def workDistributor(stockList,threadCounts):
        """Distribute work to workers"""
        #Total 
        TOTAL=len(stockList)
        reshapedList=np.array(stockList).reshape(threadCounts,(TOTAL/threadCounts))
        for i in reshapedList:
            Worker(i).start()

    # Read mainboard stock into list
    FILE='~/Desktop/PandasFinance/MainBoardList.txt'                        
    MainBoardStockList=CleanStock(FILE)
    MainBoardStockList=MainBoardStockList[0:2000]
    workDistributor(MainBoardStockList,10)

0 个答案:

没有答案