Title: forkserver requires a writeable temp file system · Issue #155717 · python/cpython · GitHub
Open Graph Title: forkserver requires a writeable temp file system · Issue #155717 · python/cpython
X Title: forkserver requires a writeable temp file system · Issue #155717 · python/cpython
Description: Bug report Bug description: We run containers in our k8s without any writeable filesystem (readOnlyRootFilesystem=True), including no writeable temp file system. The following code therefore raises: >>> tempfile._get_default_tempdir() Tr...
Open Graph Description: Bug report Bug description: We run containers in our k8s without any writeable filesystem (readOnlyRootFilesystem=True), including no writeable temp file system. The following code therefore raises...
X Description: Bug report Bug description: We run containers in our k8s without any writeable filesystem (readOnlyRootFilesystem=True), including no writeable temp file system. The following code therefore raises...
Opengraph URL: https://github.com/python/cpython/issues/155717
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"forkserver requires a writeable temp file system","articleBody":"# Bug report\n\n### Bug description:\n\nWe run containers in our k8s without any writeable filesystem ([readOnlyRootFilesystem=True](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)), including no writeable temp file system.\n\nThe following code therefore raises:\n\n```shell\n>>> tempfile._get_default_tempdir()\nTraceback (most recent call last):\n File \"\u003cpython-input-1>\", line 1, in \u003cmodule>\n tempfile._get_default_tempdir()\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n File \"/usr/lib/python3.14/tempfile.py\", line 222, in _get_default_tempdir\n raise FileNotFoundError(_errno.ENOENT,\n \"No usable temporary directory found in %s\" %\n dirlist)\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']\n```\n\nUnfortunately, multiprocessing defaults to forkserver (in this case started by granian, see https://github.com/emmett-framework/granian/issues/905):\n\nhttps://github.com/python/cpython/blob/5d3f02a5c339f03fc377bacd40a83eb9217ffddb/Lib/multiprocessing/context.py#L326-L339\n\nAnd then fails if it started on such a read only filesystem.\n\n```shell\n[INFO] Starting granian (main PID: 1)\n[INFO] Listening at: http://0.0.0.0:8009\nTraceback (most recent call last):\n File \"/opt/app/venv/bin/granian\", line 10, in \u003cmodule>\n sys.exit(cli.entrypoint())\n ~~~~~~~~~~~~~~^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/cli.py\", line 606, in entrypoint\n cli(auto_envvar_prefix='GRANIAN')\n ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/click/core.py\", line 1524, in __call__\n return self.main(*args, **kwargs)\n ~~~~~~~~~^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/click/core.py\", line 1445, in main\n rv = self.invoke(ctx)\n File \"/opt/app/venv/lib/python3.14/site-packages/click/core.py\", line 1308, in invoke\n return ctx.invoke(self.callback, **ctx.params)\n ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/click/core.py\", line 877, in invoke\n return callback(*args, **kwargs)\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/cli.py\", line 600, in cli\n server.serve()\n ~~~~~~~~~~~~^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/mp.py\", line 513, in serve\n super().serve(spawn_target, target_loader, wrap_loader)\n ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/common.py\", line 760, in serve\n serve_method(spawn_target, target_loader)\n ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/common.py\", line 588, in _serve\n self.startup(spawn_target, target_loader)\n ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/common.py\", line 494, in startup\n self._spawn_workers(spawn_target, target_loader)\n ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/common.py\", line 346, in _spawn_workers\n wrk.start()\n ~~~~~~~~~^^\n File \"/opt/app/venv/lib/python3.14/site-packages/granian/server/common.py\", line 72, in start\n self.inner.start()\n ~~~~~~~~~~~~~~~~^^\n File \"/usr/lib/python3.14/multiprocessing/process.py\", line 121, in start\n self._popen = self._Popen(self)\n ~~~~~~~~~~~^^^^^^\n File \"/usr/lib/python3.14/multiprocessing/context.py\", line 306, in _Popen\n return Popen(process_obj)\n File \"/usr/lib/python3.14/multiprocessing/popen_forkserver.py\", line 35, in __init__\n super().__init__(process_obj)\n ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n File \"/usr/lib/python3.14/multiprocessing/popen_fork.py\", line 20, in __init__\n self._launch(process_obj)\n ~~~~~~~~~~~~^^^^^^^^^^^^^\n File \"/usr/lib/python3.14/multiprocessing/popen_forkserver.py\", line 51, in _launch\n self.sentinel, w = forkserver.connect_to_new_process(self._fds)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^\n File \"/usr/lib/python3.14/multiprocessing/forkserver.py\", line 89, in connect_to_new_process\n self.ensure_running()\n ~~~~~~~~~~~~~~~~~~~^^\n File \"/usr/lib/python3.14/multiprocessing/forkserver.py\", line 166, in ensure_running\n address = connection.arbitrary_address('AF_UNIX')\n File \"/usr/lib/python3.14/multiprocessing/connection.py\", line 82, in arbitrary_address\n return os.path.join(util.get_temp_dir(),\n ~~~~~~~~~~~~~~~~~^^\n File \"/usr/lib/python3.14/multiprocessing/util.py\", line 216, in get_temp_dir\n base_tempdir = _get_base_temp_dir(tempfile)\n File \"/usr/lib/python3.14/multiprocessing/util.py\", line 171, in _get_base_temp_dir\n base_tempdir = tempfile.gettempdir()\n File \"/usr/lib/python3.14/tempfile.py\", line 312, in gettempdir\n return _os.fsdecode(_gettempdir())\n ~~~~~~~~~~~^^\n File \"/usr/lib/python3.14/tempfile.py\", line 305, in _gettempdir\n tempdir = _get_default_tempdir()\n File \"/usr/lib/python3.14/tempfile.py\", line 222, in _get_default_tempdir\n raise FileNotFoundError(_errno.ENOENT,\n \"No usable temporary directory found in %s\" %\n dirlist)\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/workdir']\n```\n\nGiven that it already checks for some other problems (the SEND_HANDLE) and defaults to spawn if there are problems, it would be nice to also check for read only tempfiles and default to spawn in that case.\n\ne.g. something long the lines of \n\n```py\ntry:\n tempfile.gettempdir()\n CAN_RUN_FORKERSERVER = True\nexcept FileNotFoundError: # read only filesystem\n CAN_RUN_FORKERSERVER = False\n```\n\nAnd then use that similarly to `HAVE_SEND_HANDLE`.\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155827\n* gh-155886\n* gh-155887\n* gh-155891\n* gh-158410\n* gh-159254\n* gh-159271\n* gh-159273\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/jankatins","@type":"Person","name":"jankatins"},"datePublished":"2026-08-13T14:53:57Z","url":"https://github.com/python/cpython/issues/155717"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8fa3b79d-84d0-c46a-d18b-6d4a52ec155a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABCC:2A1EC8:DB64E0:113BBCB:6B023379 |
| html-safe-nonce | c7a00fb11387399fc53c1ee55fb7b9f4dab6abbff550fa06e7b6f814dc949c8d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkNDOjJBMUVDODpEQjY0RTA6MTEzQkJDQjo2QjAyMzM3OSIsInZpc2l0b3JfaWQiOiI0NTI4ODUxNjgzMjI0MjA0MTUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2d904132c982f32a64fb6840df82ee671b214b2cf57a0777cf1030bbbc790e41 |
| hovercard-subject-tag | issue:5142695333 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/155717/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c26fc3e2c72305f9667d213960fec225090f65bb6e4f97eb910f792f7027b143/python/cpython/issues/155717 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c26fc3e2c72305f9667d213960fec225090f65bb6e4f97eb910f792f7027b143/python/cpython/issues/155717 |
| og:image:alt | Bug report Bug description: We run containers in our k8s without any writeable filesystem (readOnlyRootFilesystem=True), including no writeable temp file system. The following code therefore raises... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jankatins |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width