Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCPClient error check Gearman worker creation #674

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/MCPClient/lib/archivematicaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,27 @@ def executeCommand(gearman_worker, gearman_job):
@auto_close_db
def startThread(threadNumber):
"""Setup a gearman client, for the thread."""
gm_worker = gearman.GearmanWorker([django_settings.GEARMAN_SERVER])
hostID = gethostname() + "_" + threadNumber.__str__()
gm_worker.set_client_id(hostID)
for key in supportedModules.keys():
logger.info('Registering: %s', key)
gm_worker.register_task(key, executeCommand)

failMaxSleep = 30
failSleep = 1
failSleepIncrementor = 2
while True:
try:
gm_worker.work()
except gearman.errors.ServerUnavailable as inst:
logger.error('Gearman server is unavailable: %s. Retrying in %d seconds.', inst.args, failSleep)
time.sleep(failSleep)
if failSleep < failMaxSleep:
failSleep += failSleepIncrementor
try:
gm_worker = gearman.GearmanWorker([django_settings.GEARMAN_SERVER])
hostID = gethostname() + "_" + threadNumber.__str__()
gm_worker.set_client_id(hostID)
for key in supportedModules.keys():
logger.info('Registering: %s', key)
gm_worker.register_task(key, executeCommand)

failMaxSleep = 30
failSleep = 1
failSleepIncrementor = 2
while True:
try:
gm_worker.work()
except gearman.errors.ServerUnavailable as inst:
logger.error('Gearman server is unavailable: %s. Retrying in %d seconds.', inst.args, failSleep)
time.sleep(failSleep)
if failSleep < failMaxSleep:
failSleep += failSleepIncrementor
except:
logger.error('Unable to create Gearman worker. Review "MCPClient" configuration item "MCPArchivematicaServer".')


def startThreads(t=1):
Expand Down