Skip to content
This repository has been archived by the owner on Jul 23, 2018. It is now read-only.

Commit

Permalink
Refs #15. Trying to understand twisted thread mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
rverchere committed Sep 9, 2017
1 parent ccda381 commit db38caf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# Twisted
from twisted.web.server import Site, NOT_DONE_YET
from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.internet.task import deferLater
from twisted.internet import reactor, threads

# VMWare specific imports
from pyVmomi import vim, vmodl
Expand Down Expand Up @@ -53,8 +52,7 @@ def render_GET(self, request):
if not request.args.get('target', [None])[0]:
request.setResponseCode(404)
return 'No target defined\r\n'.encode()
d = deferLater(reactor, 0, lambda: request)
d.addCallback(self.generate_latest_target)
d = threads.deferToThread(self.generate_latest_target, request)
d.addErrback(self.errback, request)
return NOT_DONE_YET
else:
Expand Down

0 comments on commit db38caf

Please sign in to comment.