pyinstaller / pyinstaller/pyinstaller
Bundle folder not available in DaemonContext
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.1k
- Forks
- 2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 11
Description
-
The DaemonContext recipe doesn't do anything. The list of fds it examines is empty.
-
The bundle folder goes away. I'm guessing this is because DaemonContext (and other daemonizers), fork and the initial process exits. This is why I can't find a cacert.pem. Is there a way to keep the folder around until the child exits?
import logging
from logging.handlers import SysLogHandler
import daemon
import os
import psutil
import sys
import time
logging.basicConfig(
datefmt='%m/%d %H:%M:%S',
format='%(asctime)s;%(name)s;%(levelname)s;%(message)s')
def getLogger(name, syslog_too=False):
log = logging.getLogger(str(name))
if syslog_too:
h = SysLogHandler('/dev/log')
fmt = '%(name)s;%(levelname)s;%(message)s'
h.setFormatter(logging.Formatter(fmt))
log.addHandler(h)
log.setLevel("INFO")
return log
log = getLogger('test', True)
def log_mei(prefix):
log.info("%s %s %s", prefix, sys._MEIPASS,
"exists" if os.path.exists(sys._MEIPASS) else "does not exist")
log.info('before frozen test')
fds_to_myself = []
if getattr(sys, 'frozen', False):
fds_to_myself.extend(
[of.fd for of in psutil.Process(os.getpid()).open_files()
if of.path == sys.executable]
)
log.info('Known fds %s', psutil.Process(os.getpid()).open_files())
log.info('fds_to_myself %s', fds_to_myself)
log_mei("outside context:")
with daemon.DaemonContext(files_preserve=fds_to_myself):
log_mei("inside context:")
time.sleep(10)
log_mei("after sleep:")
Jan 5 18:19:13 potamus test;INFO;before frozen test
Jan 5 18:19:13 potamus test;INFO;Known fds []
Jan 5 18:19:13 potamus test;INFO;fds_to_myself []
Jan 5 18:19:13 potamus test;INFO;outside context: /tmp/_MEIvTqJZZ exists
Jan 5 18:19:13 potamus test;INFO;inside context: /tmp/_MEIvTqJZZ does not exist
Jan 5 18:19:15 potamus ntpd[3973]: Soliciting pool server 91.189.89.199
Jan 5 18:19:23 potamus test;INFO;after sleep: /tmp/_MEIvTqJZZ does not exist
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DaemonContext recipe and the supplied frozen Python reproducer, especially files_preserve and the sys._MEIPASS existence checks. Trace bundle cleanup across the daemon fork and initial-process exit, then verify that the bundle remains available until the child exits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100