Fixed control-C bug

This commit is contained in:
Ross Scroggs
2024-05-28 13:06:19 -07:00
parent 33d9949283
commit db95cbcfa4
5 changed files with 28 additions and 13 deletions

View File

@@ -2,6 +2,11 @@
Merged GAM-Team version
6.76.07
Fixed bug where control-C was not recognized when GAM had processed all rows in a CSV file
and was `Waiting for N running processes to finish before terminating`.
6.76.06
Fixed bug in `gam <UserTypeEntity> print messages ... positivecountsonly` where message counts with value 0 were deiplayed.

View File

@@ -9695,16 +9695,18 @@ def MultiprocessGAMCommands(items, showCmds):
GM.Globals[GM.MULTIPROCESS_EXIT_PROCESSING] = True
def signal_handler(sig, frame):
controlC['trapped'] = True
nonlocal controlC
controlC = True
def handleControlC(source):
nonlocal controlC
batchWriteStderr(f'Control-C (Multiprocess-{source})\n')
setSysExitRC(KEYBOARD_INTERRUPT_RC)
batchWriteStderr(Msg.BATCH_CSV_TERMINATE_N_PROCESSES.format(currentISOformatTimeStamp(),
numItems, poolProcessResults[0],
PROCESS_PLURAL_SINGULAR[poolProcessResults[0] == 1]))
pool.terminate()
controlC['trapped'] = False
controlC = False
if not items:
return
@@ -9758,7 +9760,7 @@ def MultiprocessGAMCommands(items, showCmds):
else:
mpQueueCSVFile = None
# signal.signal(signal.SIGINT, origSigintHandler)
controlC = {'trapped': False}
controlC = False
signal.signal(signal.SIGINT, signal_handler)
batchWriteStderr(Msg.USING_N_PROCESSES.format(currentISOformatTimeStamp(),
numItems, numPoolProcesses,
@@ -9769,7 +9771,7 @@ def MultiprocessGAMCommands(items, showCmds):
for item in items:
if GM.Globals[GM.MULTIPROCESS_EXIT_PROCESSING]:
break
if controlC['trapped']:
if controlC:
break
if item[0] == Cmd.COMMIT_BATCH_CMD:
batchWriteStderr(Msg.COMMIT_BATCH_WAIT_N_PROCESSES.format(currentISOformatTimeStamp(),
@@ -9839,7 +9841,7 @@ def MultiprocessGAMCommands(items, showCmds):
break
time.sleep(1)
processWaitStart = time.time()
if not controlC['trapped']:
if not controlC:
if GC.Values[GC.PROCESS_WAIT_LIMIT] > 0:
waitRemaining = GC.Values[GC.PROCESS_WAIT_LIMIT]
else:
@@ -9857,6 +9859,9 @@ def MultiprocessGAMCommands(items, showCmds):
for p in completedProcesses:
del poolProcessResults[p]
if poolProcessResults[0] > 0:
if controlC:
handleControlC('SIG')
break
time.sleep(5)
if GC.Values[GC.PROCESS_WAIT_LIMIT] > 0:
delta = int(time.time()-processWaitStart)