Skip to content

Conversation

@magnusvmt
Copy link
Contributor

Popen.communicate() supports a timeout argument which is useful in case
there is a risk that the probe hangs indefinitely.

Popen.communicate() supports a timeout argument which is useful in case
there is a risk that the probe hangs.
@spirulence
Copy link

spirulence commented Oct 30, 2019

@magnusvmt couple of questions from an interested bystander -

  • I don't think python 2.7 has the equivalent parameter, so this appears to break Python 2 and PyPy compatibility, see the failing check. What's the best way to resolve that?
  • ffprobe also takes a timeout parameter, does adding an argument for it here prevent it from being passed down?

@153957
Copy link
Contributor

153957 commented Oct 31, 2019

What's the best way to resolve that?

Wait 2 months, then Python 2.7 will no longer be supported.

@kkroening
Copy link
Owner

Maybe something like this:

communicate_kwargs = {}
if timeout is not None:
    communicate_kwargs['timeout'] = timeout
out, err = p.communicate(**communicate_kwargs)

Of course, if someone specifies timeout on Python 2, they'll get an error, but that's probably not worth worrying about so long as the tests pass.

Relatedly, there should be a test for use of this newly-added timeout param, at least for Python >= 3

Fix for Python2 so that timeout is only used as keyword argument if it
is provided

Added a test for the new timeout argument that will run for Python >
3.3.
@magnusvmt
Copy link
Contributor Author

magnusvmt commented Nov 2, 2019

@spirulence

  • I don't think python 2.7 has the equivalent parameter, so this appears to break Python 2 and PyPy compatibility, see the failing check. What's the best way to resolve that?

Fixed with the code @kkroening provided, thanks!

  • ffprobe also takes a timeout parameter, does adding an argument for it here prevent it from being passed down?

Does it really? I couldn't find anything about it here https://ffmpeg.org/ffprobe.html

@spirulence
Copy link

@magnusvmt it's not available on every source, but it's there for a few.

ffprobe -i https://svs.gsfc.nasa.gov/vis/a010000/a013400/a013425/13425.Mercury.transit2019V3_1YouTube4k.mp4 -timeout 10000

will actually time out as opposed to

ffprobe -i https://svs.gsfc.nasa.gov/vis/a010000/a013400/a013425/13425.Mercury.transit2019V3_1YouTube4k.mp4

@kkroening kkroening merged commit 4cb7d26 into kkroening:master Dec 30, 2019
@kkroening
Copy link
Owner

Merged. This will be included in the next release. Thanks!

@MarcoRizk
Copy link

Was this ever released to pypi ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants