grid5000: fix errors and make it faster
As suggested by olasd, with mitogen.
Relates to: T3531
It is weird to add extracts of a python module (mitogen) by copying them. But that's a known requirement of mitogen, see https://github.com/mitogen-hq/mitogen/issues/568
Migrated from D7026 (view on Phabricator)