I'm trying to apply a timeout to one of my methods which normally works fine. I've tried this code on simple printing function and everything worked fine but now I'm getting error. Could you tell me where is the problem?
The method self.check_flights
should be running max __TIMEOUT__
seconds.
The code below is in a method which is in a class some_class
try:
p = multiprocessing.Process(target=self.check_flights, args=(destination, start_date , end_date_2))
p.start()
p.join(__TIMEOUT__)
if p.is_alive():
print 'TIMEOUT'
p.terminate()
p.join()
except Exception as e:
raise e
>ERROR: pickle.PicklingError: Can't pickle <class __main__.some_class at 0x02DD10A0>: it's not the same object as __main__.some_class
EDIT: This timeout solution is from THIS SO answer
EDIT 2: To elaborate it more, I'm attaching another lines of the error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\multiprocessing\forking.py", line 381, in main
self = load(from_parent)
File "C:\Python27\lib\pickle.py", line 1378, in load
return Unpickler(file).load()
File "C:\Python27\lib\pickle.py", line 858, in load
dispatch[key](self)
File "C:\Python27\lib\pickle.py", line 880, in load_eof
raise EOFError
EOFError