Skip to content

Commit

Permalink
Merge pull request #85 from valentinp72/master
Browse files Browse the repository at this point in the history
Pyro server changes
  • Loading branch information
DavidDoukhan authored Jul 2, 2024
2 parents c99d1c9 + 9002a22 commit 2ba5d27
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions scripts/ina_speech_segmenter_pyro_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8

# The MIT License
Expand Down Expand Up @@ -28,6 +28,7 @@
import numpy as np
import pandas as pd

import argparse

@Pyro4.expose
class GenderJobServer(object):
Expand Down Expand Up @@ -63,14 +64,39 @@ def get_njobs(self, msg, nbjobs=20):
self.i += nbjobs
return ret


def has_more_jobs(self):
return len(self.lsource) > 0 or len(self.ldest) > 0

if __name__ == '__main__':
# full name of the host to be used by remote clients
Pyro4.config.HOST = sys.argv[1]

daemon = Pyro4.Daemon() # make a Pyro daemon\n",
uri = daemon.register(GenderJobServer(sys.argv[2])) # register the greeting maker as a Pyro object\n",
print("Ready. Object uri =", uri)
daemon.requestLoop()
parser = argparse.ArgumentParser(
description='Start the inaSpeechSegmenter server.'
)
parser.add_argument(
'host', type=str,
help='Host/IP to use for the server.'
)
parser.add_argument(
'csvjobs', type=argparse.FileType('r'),
help='CSV file containing the list of jobs to process. ' \
'Required columns: source_path, dest_path'
)
parser.add_argument(
'--stop_after_dispatch', action='store_true',
help='If set, will stop the server when all jobs have been dispatched' \
' to clients.'
)
args = parser.parse_args()

Pyro4.config.HOST = args.host

with Pyro4.Daemon() as daemon:
server = GenderJobServer(args.csvjobs.name)
uri = daemon.register(server) # register the greeting maker as a Pyro object\n",
print("Ready. Object uri =", uri)

if args.stop_after_dispatch:
daemon.requestLoop(server.has_more_jobs)
else:
daemon.requestLoop()

print("Done.")

0 comments on commit 2ba5d27

Please sign in to comment.