-
Notifications
You must be signed in to change notification settings - Fork 17
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
Multiprocessing failure on Windows Python 3 #10
Comments
can You also give me the callers code or short example ? |
I'm trying to replace timeout_decorator here https://github.com/domainaware/checkdmarc/blob/master/checkdmarc.py#L1770 It seems to be failing here. https://github.com/domainaware/checkdmarc/blob/master/checkdmarc.py#L78 This looks more like a multiprocessing bug? |
just try to load dill on top of the file (without using the timeout decorator) - because loading dill registers another (better) pickler. It might that the pickler (dill) is the reason. Lets narrow it down a bit. |
looks like that can not be pickled : DNS_CACHE = ExpiringDict(max_len=200000, max_age_seconds=1800) just put those definitions into an extra Module and refer in the main code to that objects :
then it can be probably pickled. Just a guess - I did not test this. let me know ! |
this kind of errors can only occur under windows - i wonder, did it work with the original timeout_decorator under Windows ? |
I just tried importing the cache objects from a separate module and importing dill first, and got the exact same exception chain. the original timeout_decorator does not work on Windows at all at all, because it relies on UNIX signals, which lead me to look for alternatives . |
hang on, I look into it - but its not an issue of the wrapt_timeout_decorator itself. |
well, it kind of does - You need to pass @timeout(5, use_signals=True) but is even more picky when it comes to which objects can be pickled. |
ok, got it -
I also notified the Author of ExpiringDict, see : |
Thanks. That fixed that problem, and unfortunately uncovered a new one, this time around SSLContext objects from ssl: domainaware/checkdmarc@9115659
So then I tired to fix that by passing a SSLContext object before the decorated method, but it turns out SSLContext objects can't be pickled. domainaware/checkdmarc@ff32a33
Any suggestions on a workaround? |
in general, You should narrow down what really needs to be timed-out :
Under Linux it is no problem to generously spray the code with timeouts - under Windows You need to take care, because the decorated function needs to be pickable. So for multiplatform code, I tend to develop and test under Windows first - because it is the most limited system (no fork, no signals) - and after that, test under Linux - most likely it will run there anyway. I will add a small conveniance function for You to show the cause of non-pickable objects or types when possible (dill does not cover all cases unfortunately) I looked a bit at Your project and I did not find a test to provoke the timeout ?
|
I extended the Class expiringdict for You - it can be pickled now with dill. so You can let Your code unchanged if You use that version. it looks like the project is not taking care of - they almost never merge anything, probably I will lauch my own version, it somehow fits to the wrapt_timeout_decorator |
Thanks. It's hard to have a test for this that reliably times out, because it's based on what the server at the other end of the TCP connection does. If a SMTP server does not exist, most will refuse the connection outright, but some will let the connection hang and time out. I know of a few servers that reliably do this, but I'd rather not have my tests depend on a third-party's misconfigured server. That said, adding code coverage would be good. I'll work on that. I've refactored my use of the timeout decorator to only apply to the actual SMTP connection, as you suggested, which eliminates the need to pickle domainaware/checkdmarc@a9c7365 Unfortunately, It looks like that project is still pretty active? |
then You should create some misbehaving SMTP Servers Yourself (probably more then one, with different misbehaving), it should not be that hard, in order to have an idependent full testsuite. I also created a convenience function to be able to quickly test in dreampie or whatever You use: https://github.com/bitranox/wrapt_timeout_decorator#convenience-function-to-detect-pickle-errors I will release it shortly. |
Will do at some point. One last question for you, mostly out of curiosity: Why isn't this package on PyPI yet? It seems mature and stable, and I noticed that you have a placeholder badge for PyPI in the README. |
I consider not 100% covered as broken ;-) However - it is released now, You may update, the pickle analyzer should work.
I did not catch the time - I have a lot to code ... I might look into it in the future. Some small tests for the "setup.py test" are still missing - not a priority ATM, also I want to integrate WINE testing - not that it is important for that program. I gave up on jython - if You know how to test, let me know. Have fun ! |
FYI the package is now released on PyPi |
The text was updated successfully, but these errors were encountered: