-
Notifications
You must be signed in to change notification settings - Fork 93
Description
with code:
import time
import timeout_decorator
@timeout_decorator.timeout(3,use_signals=False)
def mytest():
time.sleep(5)
return 5
mytest()
get:
Output exceeds the size limit. Open the full output data in a text editor
PicklingError Traceback (most recent call last)
Cell In[24], line 8
6 time.sleep(5)
7 return 5
----> 8 mytest()
File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\timeout_decorator\timeout_decorator.py:92, in timeout..decorate..new_function(*args, **kwargs)
89 @wraps(function)
90 def new_function(*args, **kwargs):
91 timeout_wrapper = _Timeout(function, timeout_exception, exception_message, seconds)
---> 92 return timeout_wrapper(*args, **kwargs)
File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\timeout_decorator\timeout_decorator.py:147, in _Timeout.call(self, *args, **kwargs)
143 self.__process = multiprocessing.Process(target=_target,
144 args=args,
145 kwargs=kwargs)
146 self.__process.daemon = True
--> 147 self.__process.start()
148 if self.__limit is not None:
149 self.__timeout = self.__limit + time.time()
File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py:121, in BaseProcess.start(self)
118 assert not _current_process._config.get('daemon'),
119 'daemonic processes are not allowed to have children'
...
58 def dump(obj, file, protocol=None):
59 '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60 ForkingPickler(file, protocol).dump(obj)
PicklingError: Can't pickle : it's not the same object as main.mytest
Does anyone have any solution?