Skip to content

Commit

Permalink
run gr_decoder on separate process
Browse files Browse the repository at this point in the history
  • Loading branch information
baskiton committed Sep 23, 2024
1 parent 132cc2d commit 624f948
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tools/client_server/gr_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,24 @@ def process(fp: pathlib.Path, params: dict):

x = executor.action()
print(x)


def _process(fp: pathlib.Path, params: dict, q: mp.Queue = None):
logger = logging.getLogger()
logger.handlers.clear()
logger.setLevel(mp.get_logger().level)
if q is not None:
qh = logging.handlers.QueueHandler(q)
logger.addHandler(qh)
log = logging.getLogger('GRProcess')

try:
process(fp, params)
except:
log.error('process error:', exc_info=True)


def process2(fp: pathlib.Path, params: dict, log: logging.Logger = None):
p = mp.Process(target=_process, args=(fp, params, log))
p.start()
p.join()
2 changes: 1 addition & 1 deletion tools/client_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def action(self):

try:
self.log.info('Decode processing')
gr_decoder.process(fp, params)
gr_decoder.process2(fp, params, self.q)
except:
self.log.error('gr_decoder')

Expand Down

0 comments on commit 624f948

Please sign in to comment.