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.

loky crash when used from a uwsgi process

See original GitHub issue

When issuing a HTTP request on a uswgi app that uses loky one get the following error messages:

unable to load configuration from from loky.backend.semaphore_tracker import main; main(10)
Fri Apr 19 16:39:13 2019 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip 127.0.0.1) !!!
/home/ogrisel/miniconda3/envs/pip/lib/python3.7/site-packages/loky/backend/semaphore_tracker.py:74: UserWarning: semaphore_tracker: process died unexpectedly, relaunching.  Some semaphores might leak.
  warnings.warn('semaphore_tracker: process died unexpectedly, '
/home/ogrisel/miniconda3/envs/pip/bin/uwsgi: unrecognized option '--process-name'
getopt_long() error
/home/ogrisel/miniconda3/envs/pip/bin/uwsgi: unrecognized option '--process-name'
getopt_long() error
/home/ogrisel/miniconda3/envs/pip/bin/uwsgi: unrecognized option '--process-name'
getopt_long() error
unable to load configuration from from loky.backend.semaphore_tracker import main; main(11)
/home/ogrisel/miniconda3/envs/pip/bin/uwsgi: unrecognized option '--process-name'
getopt_long() error

and then:

Traceback (most recent call last):
/home/ogrisel/miniconda3/envs/pip/bin/uwsgi: unrecognized option '--process-name'
getopt_long() error
  File "loky_wsgi_app.py", line 8, in application
    result = e.submit(lambda: 42).result()
  File "/home/ogrisel/miniconda3/envs/pip/lib/python3.7/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/home/ogrisel/miniconda3/envs/pip/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
loky.process_executor.TerminatedWorkerError: A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker. The exit codes of the workers are {EXIT(1), EXIT(1), EXIT(1)}

Steps to reproduce

  • Install uswgi: for some reason I could not compile it with recent gcc versions, but it works with clang, e.g.:
CC=clang-7 pip install uswgi
  • write a small uswgi app that uses loky, for instance a file named “loky_wsgi_app.py” with the following content:
from loky import get_reusable_executor


def application(env, start_response):
    e = get_reusable_executor()
    result = e.submit(lambda: 42).result()

    start_response('200 OK', [('Content-Type','text/html')])
    return [b"%d" % result]

Start the server:

uwsgi --http :9999 --wsgi-file loky_wsgi_app.py

and navigate to http://localhost:9999 .

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ogriselcommented, Jan 10, 2020

To fix this we basically need to find a python executable in the parent folder of the uwsgi executable pointed by sys.executable that can import loky from the same installation path (under that is under site-packages folder).

If several Python versions are installed this might be a bit expensive to do so this should be cached.

0reactions
ogriselcommented, Jan 29, 2020

If someone wants to volunteer to implement the strategy described here: https://github.com/joblib/loky/issues/207#issuecomment-485137208

Read more comments on GitHub >

github_iconTop Results From Across the Web

UWSGI crash when started as service and POST big file
HTTP request can be repeated, no crash. Crash when: Use this configuration uwsgi file, /etc/uwsgi/apps-available/test_upload.ini with symbolic ...
Read more >
uWSGI Documentation - Read the Docs
The uWSGI project aims at developing a full stack for building (and hosting) clustered/distributed network applica-.
Read more >
Dockerizing Django, uWSGI and Postgres the serious way
Let's use that python3 image now. FROM python:3.6 RUN apt-get update && \ apt-get install -y && \ pip3 install uwsgi.
Read more >
uwsgi Changelog - pyup.io
They allow customizing a vassal soon after its process has been created. The first third-party plugin using it is 'apparmor': https://github.com/unbit/uwsgi- ...
Read more >
Nginx / uWsgi crashing about once an hour, please help - Reddit
Look around the "prematurely closed" message. You can then debug by sending the same request. Hopefully if you can reproduce it'll be easy...
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