Issue #6 open

Remove loops and services from Application on the fly

Gustaw Lewandowski
created an issue

Hi,

I created a patch allowing remove services and loops on running application. It would be use for example for run service in given time period etc.

Example:

{{{

!python

from diesel import Application, Service, Loop, sleep from diesel.protocols import http

Pre-gen, since it's static..

content = "Hello, World!" headers = http.HttpHeaders() headers.add('Content-Length', len(content)) headers.add('Content-Type', 'text/plain')

def hello_http(req): return http.http_response(req, 200, headers, content)

def http_manager(): while True: app.add_service(Service(http.HttpServer(hello_http),\ 8888, name='http')) print "HTTP server start" yield sleep(10) app.del_service('http') print "HTTP server stop" yield sleep(10)

app = Application() app.add_loop(Loop(http_manager)) app.run() }}}

Thanks, Gustaw

Comments (2)

  1. Log in to comment