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

[ray client] use is / is not on type check #46464

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/ray/util/client/client_pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def persistent_id(self, obj):
elif isinstance(obj, ClientRemoteFunc):
if obj._ref is None:
obj._ensure_ref()
if type(obj._ref) == InProgressSentinel:
if type(obj._ref) is InProgressSentinel:
return PickleStub(
Copy link

@kevbanawis kevbanawis Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use isinstance(ob._refj, InProgressSentinel) here?
Its more concise, readable, and faster?

https://switowski.com/blog/type-vs-isinstance/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjyao ? I am just fixing the lint..

instance will also allow sub class instances. I am not sure if it is safe for this case.

type="RemoteFuncSelfReference",
client_id=self.client_id,
Expand All @@ -114,7 +114,7 @@ def persistent_id(self, obj):
elif isinstance(obj, ClientActorClass):
if obj._ref is None:
obj._ensure_ref()
if type(obj._ref) == InProgressSentinel:
if type(obj._ref) is InProgressSentinel:
return PickleStub(
type="RemoteActorSelfReference",
client_id=self.client_id,
Expand Down
2 changes: 1 addition & 1 deletion python/ray/util/client/server/proxier.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def __next__(self):
# not its subsclasses. ex: grpc._Rendezvous
# https://github.com/grpc/grpc/blob/v1.43.0/src/python/grpcio/grpc/_server.py#L353-L354
# This fixes the https://github.com/ray-project/ray/issues/23865
if type(e) != grpc.RpcError:
if type(e) is not grpc.RpcError:
raise e # re-raise other grpc exceptions
logger.exception(
"Stop iterating cancelled request stream with the following exception:"
Expand Down