mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-16 08:15:19 +02:00
Add chunk notion for parallelization and implement specific updateInternals in CameraInit node
* Add chunk notion for parallelization * Allows Node desc to implement custom updateInternals * CameraInit node implement a specific updateInternals to update the input image list * FeatureExtraction, FeatureMatching, DepthMap, DepthMapFilter: implement parallelization
This commit is contained in:
parent
39f6ef3d64
commit
1e4f8f8a61
14 changed files with 614 additions and 271 deletions
|
@ -2,6 +2,7 @@ from collections import defaultdict
|
|||
import psutil
|
||||
import time
|
||||
import threading
|
||||
import signal
|
||||
|
||||
|
||||
def bytes2human(n):
|
||||
|
@ -187,27 +188,31 @@ bytesPerGiga = 1024. * 1024. * 1024.
|
|||
|
||||
|
||||
class StatisticsThread(threading.Thread):
|
||||
def __init__(self, node):
|
||||
def __init__(self, chunk):
|
||||
threading.Thread.__init__(self)
|
||||
self.node = node
|
||||
signal.signal(signal.SIGINT, signal.SIG_IGN) # lambda signal, frame: self.stopRequest())
|
||||
self.chunk = chunk
|
||||
self.proc = psutil.Process() # by default current process pid
|
||||
self.statistics = self.node.statistics
|
||||
self.statistics = chunk.statistics
|
||||
self._stopFlag = threading.Event()
|
||||
|
||||
def updateStats(self):
|
||||
self.lastTime = time.time()
|
||||
if self.statistics.update(self.proc):
|
||||
self.node.saveStatistics()
|
||||
if self.chunk.statistics.update(self.proc):
|
||||
self.chunk.saveStatistics()
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self.updateStats()
|
||||
if self._stopFlag.wait(60):
|
||||
# stopFlag has been set
|
||||
# update stats one last time and exit main loop
|
||||
if self.proc.is_running():
|
||||
self.updateStats()
|
||||
return
|
||||
try:
|
||||
while True:
|
||||
self.updateStats()
|
||||
if self._stopFlag.wait(60):
|
||||
# stopFlag has been set
|
||||
# update stats one last time and exit main loop
|
||||
if self.proc.is_running():
|
||||
self.updateStats()
|
||||
return
|
||||
except (KeyboardInterrupt, SystemError, GeneratorExit):
|
||||
pass
|
||||
|
||||
def stopRequest(self):
|
||||
""" Request the thread to exit as soon as possible. """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue