Skip to content

Instantly share code, notes, and snippets.

@tomprince
Created November 14, 2013 18:28
Show Gist options
  • Save tomprince/7471861 to your computer and use it in GitHub Desktop.
Save tomprince/7471861 to your computer and use it in GitHub Desktop.
from twisted.web.resource import Resource
from twisted.internet.task import LoopingCall
class R(Resource):
isLeaf = True
def getChild(self, *args):
return self
def render(self, req):
def call():
req.write("HELLO\r\n")
loop = LoopingCall(call)
loop.start(1)
req.notifyFinish().addBoth(lambda _: loop.stop())
return 1
resource = R()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment