Creating a timeout function in Python with multiprocessing
问题 I'm trying to create a timeout function in Python 2.7.11 (on Windows) with the multiprocessing library. My basic goal is to return one value if the function times out and the actual value if it doesn't timeout. My approach is the following: from multiprocessing import Process, Manager def timeoutFunction(puzzleFileName, timeLimit): manager = Manager() returnVal = manager.list() # Create worker function def solveProblem(return_val): return_val[:] = doSomeWork(puzzleFileName) # doSomeWork()