-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Descriptors not inherited on Windows #97
Comments
Well, multiprocessing works differently on windows, as there's no fork on windows. So, Can you follow up with:
That should help me gather a bit more information. |
Thanks for the quick response!
EDIT: The difference between the two logs is that in the case for the subclass, the log contains additional entries not present in the log for the parent class that are listed below (multiple entries omitted). ..... indicate passages of identical log entries for both cases.
|
Can you edit your last post to identify which trace belongs to which situation? It'd also be good to compare the trace for the failure case on Windows vs success on Linux. |
I tried to clarify this, but I could also attach the full logs. On Linux, the first section of the log is different, probably due to the different implementation of multiprocess. The following lines are only present on Windows:
After this, the log is almost the same, except for several occurrences of
on the Windows System, which I assume are symptoms of the issue. |
I was able to narrow the issue down a little further. I believe the problem lies in the fact, that class MyClass():
class Descriptor:
def __init__(self, value=None):
self.value = value
def __get__(self, instance, owner=None):
return self.value
descr = Descriptor('class default') The above code will then run, although the result will be Could you tell me how the objects are copied/reinitialized in the worker processes? FWIW, you can reproduce the exact same behavior with Ipython's |
I'm not sure what you mean about how objects are "copied/reinitialized in the worker processes". I think you are asking about how objects are passed tot he worker process. They are serialized (i.e. "pickled") with |
With regard to descriptor serialization, see |
Alright, playing around with this led me to the conclusion that my original implementation using the descriptor protocol was flawed anyway, because I actually want to store everything at instance level. I have changed my code accordingly and multiprocessing works without issue now. While this solves my actual problem, it is still curious that the above works for a class but not a subclass. |
I'm going to close this as resolved. Feel free to reopen if there's more to discuss here. |
I define a class with a custom descriptor that works very similar to a property and a method that makes use of the multiprocessing module when working with this descriptor:
The descriptor gets initialized once an instance of that class is built. Calling
MyClass().fun()
returns the expected result.Now I define a subclass:
While running
MySubClass().descr
still works as expected,MySubClass().fun()
results inMind you, this issue only comes up on a Windows machine!
I have tested it with a regular
property
instead and they work fine, so I wonder if I have to define any other special attributes for my descriptor to get it inherited properly.Is this even an issue with
pathos.multiprocess
or a flaw in the the descriptor protocol?The text was updated successfully, but these errors were encountered: