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

rpccall: extra arguments are silently ignored #131

Open
Synthetica9 opened this issue Jan 15, 2024 · 1 comment
Open

rpccall: extra arguments are silently ignored #131

Synthetica9 opened this issue Jan 15, 2024 · 1 comment

Comments

@Synthetica9
Copy link

Description

When calling a function defined by @rpccall, extra arguments are silently ignored.

To reproduce

Run the following server:

from p4p.server.thread import SharedPV
from p4p.server import Server
from p4p.nt import NTScalar

pv = SharedPV(nt=NTScalar('d'), initial=0.0)

@pv.rpc
def on_rpc(pv, op):
    print("RPC Called!")
    print(op.value().query)
    op.done()

Server.forever([{'bar:foo': pv}])

Run the following client:

from p4p.rpc import rpcproxy, rpccall
from p4p.client.thread import Context

@rpcproxy
class MyProxy(object):
    @rpccall("%s:foo")
    # Single argument needed because #130
    def foo(a='d'):
        pass

ctx = Context()
proxy = MyProxy(ctx, format="bar")

# Should fail somehow:
proxy.foo(1, 2)

Observed behaviour

Running the client succeeds, but the server only gets a single argument. Relevant output:

RPC Called!
struct {
    double a = 1
}

Expected behaviour

Should fail with an exception, probably TypeError

@mdavidsaver
Copy link
Member

Should fail with an exception, probably TypeError

Agreed. This would be done in the mcall() wrapper. Either directly, or maybe better in NTURI.wrap() where the zip() is implicitly discarding the extra positional argument.

https://github.com/mdavidsaver/p4p/blob/f5c96bad937fff57f5243f72b7fdb89a408d0f4a/src/p4p/rpc.py#L276-L279

https://github.com/mdavidsaver/p4p/blob/f5c96bad937fff57f5243f72b7fdb89a408d0f4a/src/p4p/nt/__init__.py#L275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants