grpclib icon indicating copy to clipboard operation
grpclib copied to clipboard

Allow Channel objects to be created outside of async contexts

Open FHTMitchell opened this issue 2 years ago • 2 comments

Fixes #161

FHTMitchell avatar Jul 21 '22 13:07 FHTMitchell

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.

FHTMitchell avatar Jul 21 '22 13:07 FHTMitchell

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.

vmagamedov avatar Jul 21 '22 16:07 vmagamedov