ginkgo
ginkgo copied to clipboard
Make ginkgo support Twisted programs
Looking at this, I see two paths:
- Make gservice.core.Service polymorphic on Setting('twisted'). This is in the realm of possible, but will lead to some very weird initialization code or even weirder code in the body.
- Make gservice.core.TwistedService exist, move all the gevent-specific logic out of gservice.core.Service and into gservice.core.GeventService. This is significantly less optimal because it will make a mess of the class hierarchy.
I'll take a look at going down option 1 later this week in a branch and see if clean code can be made.
Sean
Maybe to start we don't modify core at all. Twisted has it's own version of Service that runner should be able to just take from the config file.
With the coming of Context, Twisted services will need to run within these Context services to take advantage of configuration and named services. This also means Twisted will need to run with gevent. Perhaps we can do this without cluttering our class hierarchy by making an explicit TwistedContext that will start Twisted in a separate thread and start the Twisted Application there. This means regular Context won't automatically be able to load Twisted apps, but we can put special case code in the runner as opposed to anything in core or context.
Since 0.5.0, this is potentially possible (at least in theory) through AsyncManagers. It has not been researched yet.