Forums

[Error 11] Resource temporarily unavailable

I'm using moviepy and trying to save the video in my web app but I get the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/hellpanderrr/mysite/flask_app.py", line 25, in upload_file
    process(path,[5,10])
  File "/home/hellpanderrr/mysite/flask_app.py", line 50, in process
    video.write_videofile(path,fps=25,codec = 'mpeg4')
  File "<string>", line 2, in write_videofile
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<string>", line 2, in write_videofile
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<string>", line 2, in write_videofile
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 330, in write_videofile
    verbose=verbose)
  File "<string>", line 2, in write_audiofile
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 204, in write_audiofile
    verbose=verbose, ffmpeg_params=ffmpeg_params)
  File "<string>", line 2, in ffmpeg_audiowrite
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 155, in ffmpeg_audiowrite
    ffmpeg_params=ffmpeg_params)
  File "/home/hellpanderrr/.local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 80, in __init__
    self.proc = sp.Popen(cmd, **popen_params)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1223, in _execute_child
    self.pid = os.fork()
OSError: [Errno 11] Resource temporarily unavailable

I've tried reloading my app, that didn't help. What should I do?

moviepy starts processes in the background and we have a limit to how many processes each user can have running on a particular machine. It looks like your code (or perhaps moviepy) is not cleaning up after itself. At the moment, there are 2 ffmpeg processes still open (but not running or doing anything). It looks like they were started at the same time as the last reload of your web app, so I don't think they're doing anything useful.

Thank you, I forgot that I have access to process list. But I've killed them all, reloaded app and nonetheless I'm getting the same error.

The processes in the list are the ones on the console and task servers, not the web server. It looks to me like what you're doing may go over the process limit in one request, so killing them wouldn't help anyway.

Will upgrading to the paid plan help?

It might do -- paid plans can run more processes. But if the problem is that your web app is starting processes but not killing them, then it would just delay the problem until the new higher limit was reached.