Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bad idea for calling Twisted code from Django view
user_id = 2
def error(request, failure):
return 'error'
def parse(request):
def _response(r):
request.response = r
def _error(f):
r = error(request, f)
request.response = r
d = transact.Parse(user_id, request.POST['command'])
d.addCallback(_response)
d.addErrback(_error)
def _wait():
if not(d.called):
return threading.Timer(0.1, lambda: None)
t = _wait()
while(isinstance(t, threading.Timer)):
t.start()
t.join()
t = _wait()
return request.response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment