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

Revert "replace msgpack-rpc-python with mprpc" - mprpc does not install on Python 3.11 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bundle
Use Python 3 and then install the following dependencies.

```
pip install mprpc
pip install msgpack-rpc-python
```

To verify the installation, execute a sample script.
Expand Down
18 changes: 7 additions & 11 deletions rb_call.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import subprocess,time,sys,os,inspect,atexit,re
import msgpack,mprpc
import subprocess,time,sys,os,inspect,atexit
import msgpack,msgpackrpc

class RubyObject():

Expand Down Expand Up @@ -58,12 +58,9 @@ def send(self, method, *args, **kwargs):
try:
obj = self.session.client.call('send_method', self.obj_id, method, args, kwargs )
return self.cast(obj)
except mprpc.exceptions.RPCError as ex:
# data may contain space, single-quote('), double-quote(")
matched = re.match(r'ExtType\(code=40, data=b(.+)\)', ex.args[0])
if matched:
e = msgpack.ExtType(40, eval('b'+matched.group(1)) )
arg = RubyObject.cast( e )
except msgpackrpc.error.RPCError as ex:
arg = RubyObject.cast( ex.args[0] )
if isinstance( arg, RubyObject ):
raise RubyException( arg.message(), arg ) from None
else:
raise
Expand Down Expand Up @@ -105,9 +102,8 @@ def cleanup():
atexit.register( cleanup )
port = int( self.proc.stdout.readline() )
self.proc.stdout.close()
def default(obj):
return obj.to_msgpack()
self.client = mprpc.RPCClient('localhost', port, pack_encoding= None, unpack_encoding=None, pack_params = {"default": default}, unpack_params={"raw":False})
self.address = msgpackrpc.Address("localhost", port)
self.client = msgpackrpc.Client(self.address, unpack_encoding='utf-8')
RubyObject.session = self
self.kernel = RubyObject.cast( self.client.call('get_kernel') )

Expand Down