-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
Version:
python:3.11.7
grpcio:1.63.0
grpcio-tools:1.63.0
os:Windows
Hello, when I create such a channel in the program:
channel = grpc.aio.insecure_channel('localhost:50051')Afterwards, I defined two objects and used the "Union" module to provide type prompts for them. Once my "Union" list includes the name of my custom object (in this case, "Leaf"), the following error output will appear:
Error in sys.excepthook:
Original exception was:If I do not use my custom object names, such as using "str", the above errors will not occur. When using "Leaf" alone, the same problem occurs.
For more detailed information, you can refer to the comments in the code. I think this may be an internal issue with the "grpc" library, because without the code for "creating channels", there would be no error output as mentioned above. How to solve this problem, what factors are causing this phenomenon? Thank you.
Attached, problem codes and error prompts:
from typing import Union
import grpc
# Example: Creating a channel
channel = grpc.aio.insecure_channel('localhost:50051')
# In addition, if you do not use "channel" or other objects to receive results, there will be no problem.
class Leaf:
def __init__(self, stem: str):
self.stem = stem
# If only "pass" is used as a placeholder and "__ init__" is not used, then there is no problem.
# pass
class New:
def __init__(self, stem: Union[str, Leaf]):
self.stem = stem
# Using "Union" and "Leaf" will also cause problems.
# def __init__(self, stem: Union[Leaf]):
# self.stem = stem
"""
1. Using "Union" and "Leaf" Problem occurred
2. Using "Union" without "Leaf" No problem
3. Using "Union" and "str" No problem
4. Using "Leaf" No problem
5. Using "str" No problem
6. Class "Leaf" without content No problem
7. Class "Leaf" with any content Problem occurred
"""