Standalone event dispatcher pulls in eventlet

I’m looking at using the standalone event dispatcher from some code that uses gevent, and I noticed that importing event_dispatcher from nameko.standalone.events also pulls in eventlet, even though it’s not used by anything in standalone/events.py

It looks like the only reason eventlet gets pulled in is because serialization.py imports import_from_path from nameko.utils, which pulls in eventlet for the SpawningProxy, etc.

I moved import_from_path into it’s own file (pathutils.py) and verified that I can import event_dispatcher without pulling in eventlet.

What would you think about a PR to move import_from_path into it’s own file? Unfortunately it can’t go in utils since utils/init.py imports eventlet and has the bulk of the utils code in it.

Any better suggestions?

Thanks,

Bob

Hi Bob,

Thanks for reporting this. Out of curiosity, what is the side-effect of importing eventlet under gevent? The monkey-patch should not be applied, so I assumed it was harmless.

It is a bit silly that the standalone proxy imports eventlet though. It’s also inconsistent that in order to install the standalone proxy you must install eventlet (since it’s included in nameko’s requirements list).

I would happily accept a pull request that shuffled things around though. Maybe the solution is to move the eventlet-requiring utilities to nameko.utils.concurrency or similar. SpawningSet et al should only be used inside the core library so I’m not too worried about maintaining backwards-compatible paths for input.

Hi Matt,

I don’t know of any specific side-effects, I’m just trying to keep my core set of modules as “clean” as possible, to avoid debugging strange interactions, and it seemed like a good idea to minimize what gets imported by the standalone event_dispatcher.

I’ll push a PR and we can iterate on the changes.

Thanks!

Bob

1 Like