[Twisted-Python] untwisting twistd

Paul Thomas spongelavapaul at googlemail.com
Fri Jul 3 03:30:35 MDT 2009


On 2 Jul 2009, at 23:50, Mikhail wrote:

>
> In my example I should have written
>
>    run(application)
>
> instead of
>
>    run(...)
>
> Then the difference would be more apparent. Namely, in my 'wrapper'
> it is explicit what application will be run and where all the services
> came from, your 'wrapper' is just a customized version of twistd and
> what will be run depends on the command line and what will be found
> in the file system. In some cases I'd like to _explicitly_ code into
> main script what functionality my application provides and I do not
> want twistd search file system for plugins at all.

I'm not using plugins, but I had the same requirement as you to  
explicitly create the app and then run it - because I need the freeze  
scripts to make a single application.

My solution looked something like:

# myapp.py

from twisted.scripts._twistd_unix import UnixApplicationRunner
# Of course, that's just because the app is unix only


class MyRunner(UnixApplicationRunner):
	def createOrGetApplication(self):
		# The stuff that's usually in a tac file
		application = # ...
		return application

def main():
	setup_logging()
	config = { # stuff pinched by dumping 'config' during a twistd run
		}
	# Also do the ServerOptions thing here if necessary
	MyRunner(config).run()

if __name__ == '__main__'
	main()



-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090703/097bf0ef/attachment.html>


More information about the Twisted-Python mailing list