Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _reset_watchers(self):
client = self._tree._client
for _watchers in (client._data_watchers, client._child_watchers):
_path = _prefix_root(client.chroot, self._path)
_watcher = _watchers.get(_path, set())
_watcher.discard(self._process_watch)
def exists_async(self, path, watch=None):
"""Asynchronously check if a node exists. Takes the same
arguments as :meth:`exists`.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
if not isinstance(path, string_types):
raise TypeError("Invalid type for 'path' (string expected)")
if watch and not callable(watch):
raise TypeError("Invalid type for 'watch' (must be a callable)")
async_result = self.handler.async_result()
self._call(Exists(_prefix_root(self.chroot, path), watch),
async_result)
return async_result
def sync_async(self, path):
"""Asynchronous sync.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
async_result = self.handler.async_result()
self._call(Sync(_prefix_root(self.chroot, path)), async_result)
return async_result
def get_async(self, path, watch=None):
"""Asynchronously get the value of a node. Takes the same
arguments as :meth:`get`.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
if not isinstance(path, basestring):
raise TypeError("path must be a string")
if watch and not callable(watch):
raise TypeError("watch must be a callable")
async_result = self.handler.async_result()
self._call(GetData(_prefix_root(self.chroot, path), watch),
async_result)
return async_result
def delete_async(self, path, version=-1):
"""Asynchronously delete a node. Takes the same arguments as
:meth:`delete`, with the exception of `recursive`.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
if not isinstance(path, string_types):
raise TypeError("Invalid type for 'path' (string expected)")
if not isinstance(version, int):
raise TypeError("Invalid type for 'version' (int expected)")
async_result = self.handler.async_result()
self._call(Delete(_prefix_root(self.chroot, path), version),
async_result)
return async_result
def delete_async(self, path, version=-1):
"""Asynchronously delete a node. Takes the same arguments as
:meth:`delete`, with the exception of `recursive`.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
if not isinstance(path, basestring):
raise TypeError("path must be a string")
if not isinstance(version, int):
raise TypeError("version must be an int")
async_result = self.handler.async_result()
self._call(Delete(_prefix_root(self.chroot, path), version),
async_result)
return async_result
def sync_async(self, path):
"""Asynchronous sync.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
async_result = self.handler.async_result()
self._call(Sync(_prefix_root(self.chroot, path)), async_result)
return async_result
if not isinstance(value, bytes):
raise TypeError("value must be a byte string")
if not isinstance(ephemeral, bool):
raise TypeError("ephemeral must be a bool")
if not isinstance(sequence, bool):
raise TypeError("sequence must be a bool")
flags = 0
if ephemeral:
flags |= 1
if sequence:
flags |= 2
if acl is None:
acl = OPEN_ACL_UNSAFE
self._add(Create(_prefix_root(self.client.chroot, path), value, acl,
flags), None)
def exists_async(self, path, watch=None):
"""Asynchronously check if a node exists. Takes the same
arguments as :meth:`exists`.
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
"""
if not isinstance(path, basestring):
raise TypeError("path must be a string")
if watch and not callable(watch):
raise TypeError("watch must be a callable")
async_result = self.handler.async_result()
self._call(Exists(_prefix_root(self.chroot, path), watch),
async_result)
return async_result