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

Restore SIGTERM behavior to terminate subprocesses in multi-threaded augmenters #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions batchgenerators/dataloading/multi_threaded_augmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
import sys
import logging
import signal
from multiprocessing import Event
from time import sleep, time
from threadpoolctl import threadpool_limits
Expand All @@ -32,6 +33,9 @@


def producer(queue, data_loader, transform, thread_id, seed, abort_event, wait_time: float = 0.02):
# Restore default SIGTERM handler to terminate the process
signal.signal(signal.SIGTERM, signal.SIG_DFL)

np.random.seed(seed)
data_loader.set_thread_id(thread_id)
item = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from queue import Queue as thrQueue
import numpy as np
import logging
import signal
from multiprocessing import Event
from time import sleep, time

Expand All @@ -37,6 +38,9 @@

def producer(queue: Queue, data_loader, transform, thread_id: int, seed,
abort_event: Event, wait_time: float = 0.02):
# Restore default SIGTERM handler to terminate the process
signal.signal(signal.SIGTERM, signal.SIG_DFL)

# the producer will set the abort event if something happens
with threadpool_limits(1, None):
np.random.seed(seed)
Expand Down