Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
if clear_files:
shutil.rmtree(job.save_path)
for slave in self.slaves:
if slave.job == job:
slave.job = None
slave.job_frames = []
def addJob(self, job):
self.jobs.append(job)
self.jobs_map[job.id] = job
# create job directory
job.save_path = os.path.join(self.path, "job_" + job.id)
if not os.path.exists(job.save_path):
os.mkdir(job.save_path)
job.save()
def getJobID(self, id):
return self.jobs_map.get(id)
def __iter__(self):
for job in self.jobs:
yield job
if (
not self.balancer.applyExceptions(job) # No exceptions
and slave.id not in job.blacklist # slave is not blacklisted
and (not slave.tags or job.tags.issubset(slave.tags)) # slave doesn't use tags or slave has all job tags
):
return job, job.getFrames()
return None, None
def clearMaster(path):
shutil.rmtree(path)
filepath = os.path.join(path, "blender_master.data")
if not clear and os.path.exists(filepath):
print("loading saved master:", filepath)
with open(filepath, 'rb') as f:
path, jobs, slaves = pickle.load(f)
httpd = RenderMasterServer(address, RenderHandler, path, force=force, subdir=False)
httpd.restore(jobs, slaves)
return httpd
return RenderMasterServer(address, RenderHandler, path, force=force)
def saveMaster(path, httpd):
filepath = os.path.join(path, "blender_master.data")
with open(filepath, 'wb') as f:
pickle.dump((httpd.path, httpd.jobs, httpd.slaves), f, pickle.HIGHEST_PROTOCOL)
def runMaster(address, broadcast, clear, force, path, update_stats, test_break):
httpd = createMaster(address, clear, force, path)
Campbell Barton
committed
httpd.timeout = 1
httpd.stats = update_stats
Campbell Barton
committed
if broadcast:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
Campbell Barton
committed
start_time = time.time() - 2
Campbell Barton
committed
while not test_break():
try:
httpd.handle_request()
except select.error:
pass
Campbell Barton
committed
if time.time() - start_time >= 2: # need constant here
httpd.timeoutSlaves()
Campbell Barton
committed
httpd.updateUsage()
Campbell Barton
committed
if broadcast:
print("broadcasting address")
s.sendto(bytes("%i" % address[1], encoding='utf8'), 0, ('<broadcast>', 8000))
start_time = time.time()
Campbell Barton
committed
httpd.server_close()
if clear:
clearMaster(httpd.path)
else:
saveMaster(path, httpd)