Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

debug flag

  • Loading branch information...
commit 2ccc34d614395fdac2a5ff3557dce425036a7418 1 parent d9d3fba
@sampsyo authored
Showing with 10 additions and 2 deletions.
  1. +9 −1 cfut.py
  2. +1 −1  example.py
View
10 cfut.py
@@ -16,7 +16,9 @@ class RemoteException(object):
pass
class CondorExecutor(futures.Executor):
- def __init__(self):
+ def __init__(self, debug=False):
+ self.debug = debug
+
self.wait_thread = condor.WaitThread(self._completion)
self.wait_thread.start()
@@ -25,6 +27,9 @@ def __init__(self):
def _completion(self, jobid):
"""Called whenever a job finishes."""
fut, workerid = self.jobs.pop(jobid)
+ if self.debug:
+ print >>sys.stderr, "job completed: %i" % jobid
+
with open(OUTFILE_FMT % workerid) as f:
outdata = f.read()
success, result = serialization.deserialize(outdata)
@@ -45,6 +50,9 @@ def submit(self, fun, *args, **kwargs):
f.write(funcser)
jobid = condor.submit(sys.executable, '-m cfut %s' % workerid)
+ if self.debug:
+ print >>sys.stderr, "job submitted: %i" % jobid
+
# Thread will wait for it to finish.
self.wait_thread.wait(jobid)
View
2  example.py
@@ -14,7 +14,7 @@ def hostinfo():
def example_1():
"""Square some numbers on remote hosts!
"""
- with cfut.CondorExecutor() as executor:
+ with cfut.CondorExecutor(True) as executor:
futures = [executor.submit(square, n) for n in range(5)]
for future in concurrent.futures.as_completed(futures):
print future.result()
Please sign in to comment.
Something went wrong with that request. Please try again.