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

Nameko can not work with pathlib #642

Closed
YAGregor opened this issue Jun 23, 2019 · 2 comments
Closed

Nameko can not work with pathlib #642

YAGregor opened this issue Jun 23, 2019 · 2 comments

Comments

@YAGregor
Copy link

Describe the bug
nameko worker process raise an exception when calling Path('anything').open(). reference to this issue, that should caused by a bug of eventlet.

To Reproduce
server.py

from pathlib import Path
from nameko.rpc import rpc


class Test:
    name = 'test'

    @rpc
    def test(self):
        Path('anything').open()

client.py

from nameko.standalone.rpc import ClusterRpcProxy

with ClusterRpcProxy({'AMQP_URI': 'pyamqp://guest:guest@localhost'}) as cluster_rpc:
    cluster_rpc.test.test()

run command line nameko run server and python client.py.
Expected behavior
client crushed and server raised a exception. exception on my machine:

Traceback (most recent call last):
  File "/home/***/.local/share/virtualenvs/judger-uPeNMyNf/lib/python3.7/site-packages/nameko/containers.py", line 392, in _run_worker
    result = method(*worker_ctx.args, **worker_ctx.kwargs)
  File "./server.py", line 10, in test
    Path('anything').open()
  File "/usr/lib64/python3.7/pathlib.py", line 1186, in open
    opener=self._opener)
  File "/usr/lib64/python3.7/pathlib.py", line 1039, in _opener
    return self._accessor.open(self, flags, mode)
  File "/home/***/.local/share/virtualenvs/judger-uPeNMyNf/lib/python3.7/site-packages/eventlet/green/os.py", line 107, in open
    fd = __original_open__(file, flags, mode, dir_fd=dir_fd)
TypeError: open: path should be string, bytes or os.PathLike, not _NormalAccessor

Environment (please complete the following information):

  • Nameko version: 2.12.0
  • Python version: 3.7.3
  • OS: Manjaro/Linux
@daviskirk
Copy link
Contributor

As a simple workaround, in python >= 3.6 you should be able to use the normal builtin open function on pathlib objects. This seems to work fine and should have the exact same result (but without the crash):

import pathlib 

class Test:
    name = 'test'

    @rpc
    def test(self):
        open(Path('anything'))

@davidszotten
Copy link
Member

eventlet 0.25.1 is now available with a fix for the pathlib issue

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