Skip to content

Commit

Permalink
Optional disabling of prevent_sigint.
Browse files Browse the repository at this point in the history
This is a workaround for a strange hang on fork() when `Popen` is called with
a `preexec_fn` (see #58). If the environment variable
`IMAGEIO_FFMPEG_NO_PREVENT_SIGINT` is not empty, `preexec_fn` is set to
None.
  • Loading branch information
Bulkin committed Aug 18, 2021
1 parent 615cbcc commit 117f7c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ Tidelift will coordinate the fix and disclosure.

## API

The library can be configured at runtime by setting the following environment
variables:
* `IMAGEIO_FFMPEG_EXE=[file name]` -- override the ffmpeg executable;
* `IMAGEIO_FFMPEG_NO_PREVENT_SIGINT=1` -- don't prevent propagation of SIGINT
to the ffmpeg process.

```py
def read_frames(
path,
Expand Down
6 changes: 6 additions & 0 deletions imageio_ffmpeg/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def _popen_kwargs(prevent_sigint=False):
creationflags = 0x00000200
else:
preexec_fn = os.setpgrp # the _pre_exec does not seem to work

falsy = ("", "0", "false", "no")
if os.getenv("IMAGEIO_FFMPEG_NO_PREVENT_SIGINT", "").lower() not in falsy:
# Unset preexec_fn to work around a strange hang on fork() (see #58)
preexec_fn = None

return {
"startupinfo": startupinfo,
"creationflags": creationflags,
Expand Down

0 comments on commit 117f7c3

Please sign in to comment.