This is an archive of the discontinued Mercurial Phabricator instance.

wireprotoserver: ability to run an SSH server until an event is set
ClosedPublic

Authored by indygreg on Feb 26 2018, 4:16 PM.

Details

Summary

It seems useful to be able to start an SSH protocol server that
won't run forever and won't call sys.exit() when it stops. This
could be used to facilitate intra-process testing of the SSH
protocol, for example.

We teach the server function to loop until a threading.Event is set
and invent a new API to run the server until an event is set. It also
won't sys.exit() afterwards.

There aren't many callers of serve_forever(). So we could refactor
them relatively easily. But I was lazy.

threading.Event might be a bit heavyweight. An alternative would be
a list whose only elements is changed. We can't use a simple scalar
value like a bool or int because those types are immutable. Events
are what you use in systems programming for this use case, so the
use of threading.Event seems justified.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.