python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 386 forks source link

kazoo.recipe.cache.TreeCache doesn't work on Windows because it uses backslash #680

Closed sr-mlitvin closed 1 year ago

sr-mlitvin commented 1 year ago

the recipe is using os.path.join which uses backslash on windows. https://github.com/python-zk/kazoo/blob/master/kazoo/recipe/cache.py#L339 need to use '/'.join() or similar instead

Expected Behavior

TreeCache should load the tree

Actual Behavior

Cannot load any children because uses \ on windows e.x. tries to get '/presence\tss' instead of '/presence/tss'

Snippet to Reproduce the Problem

Listen to any tree on windows

Logs with logging in DEBUG mode

DEBUG:kazoo.client:Sending request(xid=305): GetChildren(path='/presence\tss', watcher=<bound method TreeNode._process_watch of <kazoo.recipe.cache.TreeNode object at 0x000001FD4BA1E5E0>>)

Specifications

StephenSorriaux commented 1 year ago

Hi,

Thanks for the issue.

Makes perfect sense. I believe we might have some other issues with Windows, since we have not any testing for this platform.

a-ungurianu commented 1 year ago

We can probably take advantage of pathlib to get nice path manipulation semantics by explicitly using the PurePosixPath type to create the paths as needed.