question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ffmpeg_reader is creating zombie processes

See original GitHub issue

Opening a video file and deleting the variable leaves a zombie ffmpeg process running in the background. Steps to reproduce:

from moviepy.editor import VideoFileClip
import subprocess, gc

clip = VideoFileClip(PATH_TO_SOME_VIDEO)

del clip
gc.collect()

print([proc.args for proc in subprocess._active])
subprocess.run('echo hi', shell=True)

Output:

[['C:\\Users\\Rawing\\AppData\\Local\\imageio\\ffmpeg\\ffmpeg-win32-v3.2.4.exe',
 '-i', 'D:\\users\\aran-fey\\desktop\\temp {e}\\SV card videos\\101221050 Navy L
ieutenant.mkv', '-loglevel', 'error', '-f', 'image2pipe', '-vf', 'scale=959:1484
', '-sws_flags', 'bicubic', '-pix_fmt', 'rgb24', '-vcodec', 'rawvideo', '-']]
Traceback (most recent call last):
  File "temp.py", line 14, in <module>
    subprocess.run('echo hi', shell=True)
  File "C:\Python37\lib\subprocess.py", line 453, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Python37\lib\subprocess.py", line 645, in __init__
    _cleanup()
  File "C:\Python37\lib\subprocess.py", line 215, in _cleanup
    res = inst._internal_poll(_deadstate=sys.maxsize)
  File "C:\Python37\lib\subprocess.py", line 1193, in _internal_poll
    if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid

As you can see, a ffmpeg process is running. The subprocess module tries to clean it up, but fails. Evidently, this ffmpeg process is spawned by the FFMPEG_VideoReader class, as the arguments match perfectly.

Related issues: #677 #569

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
arianaa30commented, Oct 1, 2019

Thanks for the hint. I did, but still randomly get the same error.

0reactions
keikorocommented, Jan 14, 2022

Closing this since suggestions for dealing with the issue were provided.

Feel free to open a new issue following the issue template and referencing this older issue if the problem reoccurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to kill (or avoid) zombie processes with subprocess ...
When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the ......
Read more >
Creating & troubleshooting Zombie processes in Python
These processes are zombie processes. Before discussing how to troubleshoot & create a zombie process, let's discuss what a zombie process ...
Read more >
Zombie Processes and their Prevention
Zombie state: When a process is created in UNIX using fork() system call, the parent process is cloned. If the parent process calls...
Read more >
How To Hunt, Kill and Remove a Zombie Process on Linux
If a parent process continues to create zombies, repair them straight away. This is important so the parents can properly call wait() to...
Read more >
EDR: Zombie processes created by sensor
Environment EDR (CB Response) Server: All Supported Versions EDR Sensor: 7.1.0 Linux: All Supported Versions Symptoms Zombie processes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found