unhandled exception in thread started by <function indexing at >

3.1k views Asked by At

This is the function raising the error.

def indexing(stem, stopwords):
 result = sort()
 if os.path.exists('mem_F_F') == False:
     fileName = ''
     if stem == False and stopwords == False:
         fileName = 'mem_F_F'
     elif stem == False and stopwords == True:
         fileName = 'mem_F_T'
     elif stem == True and stopwords == False:
         fileName = 'mem_T_F'
     elif stem == True and stopwords == True:
         fileName = 'mem_T_T'
     writefile(fileName, result)
     print 'write mem'
     return
 if os.path.exists('mem1_F_F') == False:
     fileName = ''
     if stem == False and stopwords == False:
         fileName = 'mem1_F_F'
     elif stem == False and stopwords == True:
         fileName = 'mem1_F_T'
     elif stem == True and stopwords == False:
         fileName = 'mem1_T_F'
     elif stem == True and stopwords == True:
         fileName = 'mem1_T_T'
     writefile(fileName, result)
     documents.mergefile()  

I have called this function in another function as

def doIndex():
 thread.start_new_thread(indexing, (False, False))
 thread.start_new_thread(indexing, (False, True))
 thread.start_new_thread(indexing, (True, False))
 thread.start_new_thread(indexing, (True, True))

I tried putting it in a try-except but it does not mention what the exception is.

The error is as follows

Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by

Traceback (most recent call last) :

Traceback (most recent call last) :

Traceback (most recent call last) :

Traceback (most recent call last) :

File "C:\Users....\token,py", line 110, in indexing

File "C:\Users....\token,py", line 110, in indexing

File "C:\Users....\token,py", line 110, in indexing

File "C:\Users....\token,py", line 110, in indexing

writefile(filename, result)writefile(filename, result)writefile(filename, result)writefile(filename, result)

1

There are 1 answers

0
Jasper Fang On

Normally, this exception means the main thread ended before the sub-threads ended. simply add time.sleep(10) at the main thread may address this problem, or add some function for waiting for their end.