From 0e99678093a320b112ca86f196554e595c2654e1 Mon Sep 17 00:00:00 2001 From: Vasilij Litvinov Date: Wed, 22 Jul 2020 18:17:08 +0300 Subject: [PATCH] FEAT-#1821: Define .items() simpler Signed-off-by: Vasilij Litvinov --- modin/experimental/cloud/rpyc_proxy.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/modin/experimental/cloud/rpyc_proxy.py b/modin/experimental/cloud/rpyc_proxy.py index fad91e1864e..bda9b8d8a17 100644 --- a/modin/experimental/cloud/rpyc_proxy.py +++ b/modin/experimental/cloud/rpyc_proxy.py @@ -112,11 +112,8 @@ def sync_request(self, handler, *args): obj, attr = args else: obj, attr = args[0], '__str__' - try: - obj_class = object.__getattribute__(obj, '__class__') - except AttributeError: - obj_class = None - if type(obj).__name__ in ('numpy',) or (getattr(obj_class, '__module__', None) in ('numpy',) and obj_class.__name__ in ('dtype',)): + + if str(obj.____id_pack__[0]) in {'numpy', 'numpy.dtype'}: try: cache = self._static_cache[obj.____id_pack__] except KeyError: @@ -131,24 +128,17 @@ def sync_request(self, handler, *args): def async_request(self, handler, *args, **kw): if handler == consts.HANDLE_DEL: - obj, refcount = args - try: - obj_class = object.__getattribute__(obj, '__class__') - except AttributeError: - obj_class = None - if type(obj).__name__ in ('numpy',) or (getattr(obj_class, '__module__', None) in ('numpy',) and obj_class.__name__ in ('dtype',)): + obj, _ = args + if str(obj.____id_pack__[0]) in {'numpy', 'numpy.dtype'}: """ # we have this cached, but a deletion is requested, remove the from cache self._static_cache.pop(obj.____id_pack__, None) """ - try: - cache = self._static_cache[obj.____id_pack__] - except KeyError: - pass - else: - # object is cached by us, so ignore the request or remote end dies and cache is suddenly stale + if obj.____id_pack__ in self._static_cache: + # object is cached by us, so ignore the request or remote end dies and cache is suddenly stale; + # we shouldn't remove item from cache as it would reduce performance res = AsyncResult(self) - res._is_ready = True + res._is_ready = True # simulate finished async request return res return super().async_request(handler, *args, **kw)