progrium / ginkgo

Python service microframework
http://ginkgo.readthedocs.org
MIT License
325 stars 51 forks source link

Make ginkgo support Twisted programs #11

Open objcode opened 12 years ago

objcode commented 12 years ago

Looking at this, I see two paths:

  1. 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.
  2. 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

progrium commented 12 years ago

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.

progrium commented 12 years ago

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.

progrium commented 12 years ago

Since 0.5.0, this is potentially possible (at least in theory) through AsyncManagers. It has not been researched yet.