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.

Nuitka+fastapi+uvicorn=«multiprocessing/resource_tracker.py:96: UserWarning: resource_tracker: process died unexpectedly, relaunching»

See original GitHub issue

Consider following minimal sample project used FastAPI with uvicorn, based on pipenv for fast reproduceability. https://github.com/belonesox/fastapi-unicorn-nuitka-troubles

  • Checkout it.

  • test1.py demo service with 1 worker

  • test2.py demo run service with 2 workers

  • sh reproduce-me.sh — compile both of them

  • pure_python_ok.sh — successfully run using raw python (both 1worker and 2worker versions).

INFO:     Uvicorn running on http://0.0.0.0:8040 (Press CTRL+C to quit)
INFO:     Started parent process [1138946]
INFO:     Started server process [1138961]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Started server process [1138962]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

To check that service is working, just open http://localhost:8040/docs

  • compiled_1worker_ok.sh — run compiled nuitka version with 1 worker, OK INFO: Started server process [1139332] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8040 (Press CTRL+C to quit)
  • compiled_2worker_bad.sh — run compiled nuitka version with 2 worker, failed with test2.dist/multiprocessing/resource_tracker.py:96: UserWarning: resource_tracker: process died unexpectedly, relaunching. Some resources might leak.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
belonesoxcommented, May 26, 2022

Confirm that. Works for me on

Fedora           34 
Nuitka            0.8.2
uvicorn           0.17.6

even with 100 workers.

1reaction
kayhayencommented, May 26, 2022

This just worked for me with 2 workers. Probably a multiprocessing improvement fixed that some time ago.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python resource_tracker: process died unexpectedly when ...
Python resource_tracker: process died unexpectedly when using multiprocessing 'spawn' method in clear environment - Stack Overflow. Stack ...
Read more >
Strange behavior of Python multiprocessing package - GitLab
... UserWarning: resource_tracker: process died unexpectedly, relaunching. Some resources might leak. warnings.warn('resource_tracker: ...
Read more >
Process died unexpectedly returned from clustered engine ...
This technote outlines a possible problem with configuring clustered IBM® Rational® Build Forge® Engines, and details how it can be resolved.
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