-
Notifications
You must be signed in to change notification settings - Fork 83
Conversation
b0e20e4
to
a27a82b
Compare
It seems it fails. Only 2 errors:
Works with Python 2.7 and PyPy. Surprisingly, it seems to work with Python 3.4.4 as well. 😕 |
To reproduce import cloudpickle
import Pyro4
proxy = Pyro4.core.Proxy("PYRO:9999@host.com:4444")
proxy._pyroTimeout = 2
print(cloudpickle.dumps(proxy)) Trackeback: Traceback (most recent call last):
File "/cache/src/Pyro4/src/Pyro4/core.py", line 505, in __pyroCreateConnection
sock = socketutil.createSocket(connect=connect_location, reuseaddr=config.SOCK_REUSE, timeout=self.__pyroTimeout, nodelay=config.SOCK_NODELAY)
File "/cache/src/Pyro4/src/Pyro4/socketutil.py", line 292, in createSocket
sock.connect(connect)
socket.timeout: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "serialize124.py", line 9, in <module>
print(cloudpickle.dumps(proxy))
File "/cache/miniconda/envs/pyro4/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 829, in dumps
cp.dump(obj)
File "/cache/miniconda/envs/pyro4/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 233, in dump
return Pickler.dump(self, obj)
File "/cache/miniconda/envs/pyro4/lib/python3.6/pickle.py", line 409, in dump
self.save(obj)
File "/cache/miniconda/envs/pyro4/lib/python3.6/pickle.py", line 521, in save
self.save_reduce(obj=obj, *rv)
File "/cache/miniconda/envs/pyro4/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 697, in save_reduce
if hasattr(obj, '__transient__'):
File "/cache/src/Pyro4/src/Pyro4/core.py", line 272, in __getattr__
self._pyroGetMetadata()
File "/cache/src/Pyro4/src/Pyro4/core.py", line 587, in _pyroGetMetadata
self.__pyroCreateConnection()
File "/cache/src/Pyro4/src/Pyro4/core.py", line 539, in __pyroCreateConnection
raise ce
Pyro4.errors.CommunicationError: cannot connect to ('host.com', 4444): timed out It seems Do you think this is a |
The other error in import cloudpickle
import Pyro4
data = [42, "hello", Pyro4.core.Proxy("PYRO:dummy@dummy:4444")]
data.append(data)
print(cloudpickle.dumps(data)) |
I'm not familiar with cloudpickle nor the __transient__ dunder attribute it is using. What is it used for? Pyro doesn't recognise it as one of the "don't access this attribute remotely" attributes so it is indeed trying to fetch the value from the remote object (which isn't connected in the test case...) |
By the way, you can tell Pyro to avoid looking up the metadata by setting the METADATA config item to False. Perhaps that allows the test to complete. |
@irmen I think Would it make sense to consider that a special case in Pyro4? Or would you rather avoid it? Cross reference: cloudpipe/cloudpickle#108 |
@irmen By the way, it seems import cloudpickle
import Pyro4
Pyro4.config.METADATA = False
proxy = Pyro4.core.Proxy("PYRO:9999@host.com:4444")
proxy._pyroTimeout = 2
print(cloudpickle.dumps(proxy)) Leads to another issue:
The strange thing is that cloudpickle's Then the problem seems to be that when that is the case, it assumes Have not investigate this further. |
@irmen Yeah, it seems import Pyro4
Pyro4.config.METADATA = False
proxy = Pyro4.core.Proxy("PYRO:9999@host.com:4444")
print(hasattr(proxy, '__transient__')) It actually returns Is that expected? |
Maybe setting Perhaps adding a special case in Pyro4 is the easiest way to fix it (i.e.: set Would that be okay for you? Where would you suggest to add that fix/special case? |
When metadata=off it is expected that hasattr(proxy, "something") always returns true. This is because Pyro can't know if the remote object actually has the requested attribute or not, so it has to pretend that the proxy has "all" attributes. Hence the metadata that is normally enabled - that fixes this issue. For the AttributeError: 'tuple' object has no attribute 'copy' in cloudpickle, this I consider a bug in cloudpickle. It seems they assume __getstate__ always returns a dict. Which is not required: when you override __getstate__ AND __setstate__ (what Pyro does) you're free to use some other type, a tuple in Pyro's case. This is written in the Python docs for __setstate__. I think there's an easy fix for them, use the copy module rather than directly invoking the copy method. Finally, it's weird they have something going on with __transient__ if the same can be achieved with properly returning from a __getstate__ just the attributes that you want to be pickled. I don't see the need for a non-standard dunder attribute. I prefer not to make a special case just for __transient__ in Pyro. If anything happens in Pyro I'd like it to be a way to extend the set of special attributes, but ewwww. Just for giggles, try adding "__transient__" to Pyro4.core.Proxy.__pyroAttributes and see if that makes it work.? |
Yeah, it seems adding Here is the question/discussion I opened in cloudpickle. In case you want to follow it or add something. |
@Peque yeah the unit test suite is not stable anymore on travis, I've seen these errors before (not enough workers) Often kicking travis and letting it run te tests again fixes it 50/50 chance. I haven't had the time to look into this yet. |
Deleted comments related to the Travis errors (non-related to the cloudpickle integration) and opened a new issue #180. I will delete this one as well if you delete your last comment. 😉 Just to keep this discussion a bit cleaner... |
We can wait to see if the cloudpickle team has something to say about this. If they do not, it is up to you to decide whether or not this is to be merged. Maybe it could be merged like |
Yes it is a fairly trivial change in Pyro, but I'd like to know the rationale for that transient attribute. And perhaps it's fixable in cloudpickle, which avoids a third-party-lib-workaround in Pyro (no matter how tiny) |
Seems they merged cloudpipe/cloudpickle#110 into |
Great news. And thanks a lot btw to take the time to also update the documentation in this PR |
test_requirements.txt
Outdated
@@ -1,3 +1,4 @@ | |||
-r requirements.txt | |||
cloudpickle>=0.3.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to bump this to 0.3.2 to have their fix of removing the __transient__ attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. Will wait for next release to set the appropriate version (they might bump it to 0.4.0).
Maybe they do a release in the future 0.3.2
with just a couple of fixes to the old version but without breaking the transient
support, so I think we should better wait to know the actual version number... 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, let's wait on an official number
src/Pyro4/core.py
Outdated
@@ -221,7 +221,7 @@ class Proxy(object): | |||
["__getnewargs__", "__getnewargs_ex__", "__getinitargs__", "_pyroConnection", "_pyroUri", | |||
"_pyroOneway", "_pyroMethods", "_pyroAttrs", "_pyroTimeout", "_pyroSeq", "_pyroHmacKey", | |||
"_pyroRawWireResponse", "_pyroHandshake", "_pyroMaxRetries", "_pyroSerializer", "_Proxy__async", | |||
"_Proxy__pyroHmacKey", "_Proxy__pyroTimeout", "_Proxy__pyroConnLock"]) | |||
"_Proxy__pyroHmacKey", "_Proxy__pyroTimeout", "_Proxy__pyroConnLock", "__transient__"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can drop this attribute here again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Once the new cloudpickle
version is released, I will revert this as well to check Travis is happy with everything too. Might do it in new commits to make review easier for you, then I can squash everything in a single commit before you do the merge (don't think it makes sense to split this in more than 1 commit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on the single commit, if possible :)
Seems like they released a new cloudpickle version, they bumped it to 0.4.0 |
Reverted the ugly "fix", bumped the minimum |
Thanks a lot for this @Peque I'll add an entry to the changelog and perhaps try it out myself a little, maybe adding an example that utilizes a particular feature of cloudpickle (sending functions) |
Thanks to you for merging! 😊 |
A very basic implementation. Just to know what you think about this and to see what Travis says as well. 😉