Skip to content

Instantly share code, notes, and snippets.

@saghul
Created January 25, 2011 08:35
Show Gist options
  • Save saghul/794667 to your computer and use it in GitHub Desktop.
Save saghul/794667 to your computer and use it in GitHub Desktop.
Greenthread test with SIPSIMPLE run_in_green_thread
from twisted.internet import reactor
from eventlet.green import urllib2
from eventlet.twistedutil import join_reactor
from datetime import datetime
from sipsimple.util import run_in_green_thread
@run_in_green_thread
def bar():
print "Hi, I'm greenthread 1"
data = urllib2.urlopen("http://www.google.com/intl/en_ALL/images/logo.gif").read()
print "Got data"
reactor.callLater(5, reactor_stop)
def reactor_stop():
print "About to stop the reactor"
reactor.stop()
def foo():
bar()
def test1():
print "-- Test %s" % datetime.utcnow()
from twisted.internet.task import LoopingCall
lc = LoopingCall(test1)
lc.start(1)
reactor.callLater(0, foo)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment