0

I managed to come up with the following code, which will allow me to query a data file twice, simultaneously for different information. but, it doesnt seem to be working. Can anyone spot what I'm doing wrong here?

print('Start')
def getAllTimes(arg1):
    task1 = arg1
    if task1 == 1:
        textfile = open(logfile, 'r')
        filetext = textfile.read()
        textfile.close()
        matchesBegin = beginStr in filetext
        matchesEnd = endStr in filetext
        return(matchesBegin,matchesEnd)
    elif task1 == 2:
        AllTimeStamps = [ x.split(' ')[0][1:-1] for x in open(logfile).readlines() ]
        AllUniqTimeStamps = set(AllTimeStamps)
        return AllUniqTimeStamps
etime = 0
AllTimes = []
for etime in range(1,2):
    AllTimeZ = threading.Thread(target=getAllTimes, args=[etime])
    AllTimes.append(AllTimeZ)
    AllTimeZ.start()
for TheTimes in AllTimes:
    TheTimes.join()
    print TheTimes
print('Done')

After the above code runs, I want to make sure I can query the content of any variables created in the functions. And by variables I mean: matchesBegin, matchesEnd, AllUniqTimestamps

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
RoyMWell
  • 199
  • 1
  • 9
  • Possible duplicate of [Return value from thread](https://stackoverflow.com/questions/1886090/return-value-from-thread) – zwer Jul 13 '18 at 02:52
  • certainly not a duplicate – RoyMWell Jul 13 '18 at 03:07
  • It is a duplicate - your question boils down to asking how to return values from your threads and the linked question talks precisely about that. – zwer Jul 13 '18 at 03:20

0 Answers0