Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_pickle.PicklingError: Can't pickle <function mytest at 0x000001FACD58FC80>: it's not the same object as __main__.mytest #43

Open
hingston opened this issue Dec 1, 2017 · 2 comments

Comments

@hingston
Copy link

hingston commented Dec 1, 2017

Using the example given:

import time
import timeout_decorator


@timeout_decorator.timeout(5, use_signals=False)
def mytest():
    print("Start")
    for i in range(1, 10):
        time.sleep(1)
        print("%d seconds have passed" % i)


if __name__ == '__main__':
    mytest()

I receive:

Traceback (most recent call last):
  File "C:/Users/Will/PycharmProjects/tests/timeout.py", line 15, in <module>
    mytest()
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\site-packages\timeout_decorator\timeout_decorator.py", line 91, in new_function
    return timeout_wrapper(*args, **kwargs)
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\site-packages\timeout_decorator\timeout_decorator.py", line 146, in __call__
    self.__process.start()
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\Will\AppData\Local\Programs\Python\Python36\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <function mytest at 0x000001FACD58FC80>: it's not the same object as __main__.mytest

System info:

Windows 10
Python 3.6.3
timeout-decorator 0.4.0

@hingston
Copy link
Author

hingston commented Dec 1, 2017

There's a working solution in #37 as a temporary work around for anyone else who finds this.

@bitranox
Copy link

bitranox commented Dec 2, 2017

You can use my fork - https://github.com/bitranox/wrapt-timeout-decorator
there it works fine, I just tested ...
Yours sincerely
Robert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants