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

inspect.isfunction(rpyc_remote_function) #426

Closed
talsaiag opened this issue Dec 31, 2020 · 2 comments
Closed

inspect.isfunction(rpyc_remote_function) #426

talsaiag opened this issue Dec 31, 2020 · 2 comments

Comments

@talsaiag
Copy link

talsaiag commented Dec 31, 2020

While upgrading from 4.1.2 to 5.0.0 we had issues with objects returned over rpyc.

Commit b683c25 broke this next snippet:

import inspect
inspect.ismethod(rpyc_remote_function)  # where rpyc_remote_function is an netref pointing to a function
# returns True before commit b683c25 but False after

Same for all inspect.is* checks (eg. ismodule, ismethod, iscode, isclass...).

Environment
  • rpyc version: 4.1.3, 5.0.0
  • python version: Python3.8
  • operating system: linux & macos
Minimal example

Server:

import rpyc
from rpyc.utils.server import OneShotServer

def func():
    pass

class HelloService(rpyc.Service):
    def exposed_example(self):
        return func


if __name__ == "__main__":
    rpyc.lib.setup_logger()
    server = OneShotServer(HelloService, port=12345)
    server.start()

Client:

import rpyc
import inspect

c = rpyc.connect("localhost", 12345)
func = c.root.example()
print(inspect.isfunction(func))  # Should print(True)
@comrumino
Copy link
Collaborator

This should be fixed by #427 ... If by chance it is not fixed, please reopen.

@sergeyyatmellanox
Copy link

Running this example on rpyc 5.0.0 and python 3.8:

INFO:HELLO/12345:accepted ('127.0.0.1', 45934) with fd 4
INFO:HELLO/12345:welcome ('127.0.0.1', 45934)
DEBUG:HELLO/12345:Exception caught
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 324, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 608, in _handle_getattr
return self._access_attr(obj, name, (), "_rpyc_getattr", "allow_getattr", getattr)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 535, in _access_attr
name = self._check_attr(obj, name, param)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 525, in _check_attr
raise AttributeError("cannot access %r" % (name,))
AttributeError: cannot access 'class'
DEBUG:HELLO/12345:Exception caught
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 324, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 608, in _handle_getattr
return self._access_attr(obj, name, (), "_rpyc_getattr", "allow_getattr", getattr)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 535, in _access_attr
name = self._check_attr(obj, name, param)
File "/usr/local/lib/python3.8/site-packages/rpyc/core/protocol.py", line 525, in _check_attr
raise AttributeError("cannot access %r" % (name,))
AttributeError: cannot access 'class'
False
INFO:HELLO/12345:goodbye ('127.0.0.1', 45934)
INFO:HELLO/12345:listener closed
INFO:HELLO/12345:server has terminated

The inspect.isfunction doesn't work anymore, again.
The same goes for inspect.ismethod.

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

3 participants