from twisted.internet import reactor, protocol, threads
from twisted.web.server import Site, NOT_DONE_YET
import externalLib
def render_POST(self, request):
def handleReply(reply):
request.write(reply)
request.finish()
#some code here
res = threads.deferToThread(self.doQuery, arg1, arg2)
res.addCallback(handleReply)
return NOT_DONE_YET
def doQuery(self, ...):
#some code
return externalLib.request()