Skip to content

Using CoolProp in multiprocessing environment crashes due to missing __reduce__ in AbstractState class #2328

Answered by fwitte
fwitte asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, found a solution on how to fix it:

class SerializableAbstractState(CP.AbstractState):

    def __init__(self, back_end, fluid_name):
        self.back_end = back_end
        self.fluid_name = fluid_name

    def __reduce__(self):
        return (self.__class__, (self.back_end, self.fluid_name))

Then you simply use SerializableAbstractState as a wrapper for your AbstractState objects. Is adding the __reduce__ an idea worth adding to the CoolProp base-class? Let me know, if you think it is worth it, I'll make a PR then.

cdef class AbstractState:
"""
This class is a one-to-one python wr…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by fwitte
Comment options

You must be logged in to vote
1 reply
@fwitte
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants