Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Resolve some warnings #57

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ikegami-yukino
Copy link

Hello.
I like this library since it's fast.

However, when using mprpc, you will see various warnings. That's why we've made improvements to make mprpc more modern.

Summary

Avoid PendingDeprecationWarning

For updating msgpack, I replaced msgpack-python with msgpack, which continues to be developed. Accordingly, this pull request no longer specifies the encoding of the string sent and received via MessagePack. These changes resolve PendingDeprecationWarning.

NOTE: Python 2 users may feel inconvenience about these changes. However, Python 2 is no longer supported from this year.

Avoid ResourceWarning

When the connection is terminated, the RPCClient class requires executing the close method explicitly. Otherwise, ResourceWarning is raised because the socket is still. For this reason, the RPCClient class is modified to support the with_statement. Using the with_statement leads to avoid forgetting executing the close method.

Avoid ImportWarning

On Python 3.7, using the C-language file generated by Old Cython raise ImportWarning. Thus, I regenerated c files by Cython 0.29.16 (currently, this version is the latest).

Change support Python versions

I think stopping tests with Python 2.6 and Python 3.3 on Travis CI is better since Travis CI can not test with Python 2.6 and Python 3.3 by default.

On the other hand, I think supporting Python 3.6, 3.7, and 3.8 is better.

Appendix

Errors on mprpc 0.1.17

On Python 3.7, when I execute the command $ python setup.py test, various warnings occur as follows:

/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
tests.test_rpc.TestRPC.test_call ... /work/git/mprpc/tests/test_rpc.py:31: PendingDeprecationWarning: encoding is deprecated.
  self._server = StreamServer((HOST, PORT), TestServer())
/work/git/mprpc/tests/test_rpc.py:64: PendingDeprecationWarning: encoding is deprecated.
  client = RPCClient(HOST, PORT)
/work/git/mprpc/tests/test_rpc.py:66: PendingDeprecationWarning: encoding is deprecated, Use raw=False instead.
  ret = client.call('echo', 'message')
/work/git/mprpc/.eggs/gevent-1.4.0-py3.7-macosx-10.14-x86_64.egg/gevent/baseserver.py:26: PendingDeprecationWarning: encoding is deprecated, Use raw=False instead.
  return handle(*args_tuple)
/work/git/mprpc/tests/test_rpc.py:69: PendingDeprecationWarning: encoding is deprecated, Use raw=False instead.
  ret = client.call('echo', 'message' * 100)
/work/git/mprpc/.eggs/nose-1.3.7-py3.7.egg/nose/case.py:198: ResourceWarning: unclosed <socket object, fd=8, family=2, type=1, proto=6>
  self.test(*self.arg)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
tests.test_rpc.TestRPC.test_call_server_side_exception ... /work/git/mprpc/tests/test_rpc.py:31: PendingDeprecationWarning: encoding is deprecated.
  self._server = StreamServer((HOST, PORT), TestServer())
/work/git/mprpc/tests/test_rpc.py:74: PendingDeprecationWarning: encoding is deprecated.
  client = RPCClient(HOST, PORT)
/work/git/mprpc/tests/test_rpc.py:77: PendingDeprecationWarning: encoding is deprecated, Use raw=False instead.
  ret = client.call('raise_error')
/work/git/mprpc/.eggs/nose-1.3.7-py3.7.egg/nose/tools/nontrivial.py:62: ResourceWarning: unclosed <socket object, fd=8, family=2, type=1, proto=6>
  pass
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
tests.test_rpc.TestRPC.test_call_socket_timeout ... /work/git/mprpc/tests/test_rpc.py:86: PendingDeprecationWarning: encoding is deprecated.
  client = RPCClient(HOST, PORT, timeout=0.1)
/work/git/mprpc/tests/test_rpc.py:88: PendingDeprecationWarning: encoding is deprecated, Use raw=False instead.
  client.call('echo_delayed', 'message', 1)
/work/git/mprpc/.eggs/gevent-1.4.0-py3.7-macosx-10.14-x86_64.egg/gevent/hub.py:582: ResourceWarning: unclosed <socket object, fd=8, family=2, type=1, proto=6>
  loop.run()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
tests.test_rpc.TestRPC.test_open_and_close ... /work/git/mprpc/tests/test_rpc.py:42: PendingDeprecationWarning: encoding is deprecated.
  client = RPCClient(HOST, PORT)
ok
tests.test_rpc.TestRPC.test_open_with_timeout ... /work/git/mprpc/tests/test_rpc.py:58: PendingDeprecationWarning: encoding is deprecated.
  client = RPCClient(HOST, PORT, timeout=5.0)
ok

----------------------------------------------------------------------
Ran 5 tests in 0.372s

OK

Thank you for your consideration😊

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

Successfully merging this pull request may close these issues.

2 participants