We try to import possibly non-exiting modules on each call, which is
expensive, looking up the the module in the entire import path. This
is also pointless since the module is not expected to appear after we
found that it was not available.
Do pointless lookups, becuase older lookups overwrite previous
lookups. For example, if gevent is available, we would lookup twice,
overwriting the pure Python lookup with gevent lookup. If both gevent
and eventlet are available, we would do 3 lookups and return the
eventlet lookup.
Check for SynatxError on import looks wrong. I could not find the
code that raise this in the gevent and evetlet.
_get_original interface was strage, accepting a string, instead of
the expected module and name arguemtns, as used by
gevent.monkey.get_original.
Now we use simpler and more efficient solution:
We try to import eventlet or gevent only once
We define _get_original either using eventlet, gevent or our
implementaion.
Coverage decreased (-0.05%) when pulling 7cd774d7436911fceefaae0c7629447147a91263 on nirs:cleanup-get-original into 9c5633c82632df24eea5f7db89d76980097db2ac on ionelmc:master.
The previous code had few issues:
Now we use simpler and more efficient solution: