vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

Allow Channel objects to be created outside of async contexts #162

Open FHTMitchell opened 2 years ago

FHTMitchell commented 2 years ago

Fixes #161

FHTMitchell commented 2 years ago

Is it expected that people will want to re-use channels? In that case this will cause errors if someone tries to re-use it. In that case we should use an ephemeral _loop in _create_connection rather than setting it as a field.

vmagamedov commented 2 years ago

Is it expected that people will want to re-use channels? In that case this will cause errors if someone tries to re-use it. In that case we should use an ephemeral _loop in _create_connection rather than setting it as a field.

I think that the whole point in removing loop argument in all public-facing APIs in asyncio and here in grpclib is to assume that we always use implicitly one global event-loop to greatly simplify API.

Only in tests I know that this is not true and now also in your example with IPython.

Your PR LGTM, only mypy has some concerns.