# HG changeset patch # User Denis Laxalde # Date 1478768714 -3600 # Node ID 48f6ebd33cb99ac4c7ccab8b689689bd8c28505e # Parent 6392f34fcdad37cfd9c9ca28757f4fe45e1031f8 [pyramid] Install file listing monitored files in application home Instead of using a temporary file, that never gets deleted. Closes #16159807. diff -r 6392f34fcdad -r 48f6ebd33cb9 cubicweb/pyramid/pyramidctl.py --- a/cubicweb/pyramid/pyramidctl.py Mon Nov 14 17:48:10 2016 +0100 +++ b/cubicweb/pyramid/pyramidctl.py Thu Nov 10 10:05:14 2016 +0100 @@ -11,7 +11,6 @@ import os import signal import sys -import tempfile import time import threading import subprocess @@ -95,7 +94,6 @@ ) _reloader_environ_key = 'CW_RELOADER_SHOULD_RUN' - _reloader_filelist_environ_key = 'CW_RELOADER_FILELIST' def debug(self, msg): print('DEBUG - %s' % msg) @@ -218,17 +216,17 @@ os.dup2(0, 1) # standard output (1) os.dup2(0, 2) # standard error (2) - def restart_with_reloader(self): + def restart_with_reloader(self, filelist_path): self.debug('Starting subprocess with file monitor') - with tempfile.NamedTemporaryFile(delete=False) as f: - filelist_path = f.name + # Create or clear monitored files list file. + with open(filelist_path, 'w') as f: + pass while True: args = [self.quote_first_command_arg(sys.executable)] + sys.argv new_environ = os.environ.copy() new_environ[self._reloader_environ_key] = 'true' - new_environ[self._reloader_filelist_environ_key] = filelist_path proc = None try: try: @@ -295,10 +293,13 @@ autoreload = self['reload'] or self['debug'] daemonize = not (self['no-daemon'] or debugmode or autoreload) + cwconfig = cwcfg.config_for(appid, debugmode=debugmode) + filelist_path = os.path.join(cwconfig.apphome, + '.pyramid-reload-files.list') + if autoreload and not os.environ.get(self._reloader_environ_key): - return self.restart_with_reloader() + return self.restart_with_reloader(filelist_path) - cwconfig = cwcfg.config_for(appid, debugmode=debugmode) if autoreload: _turn_sigterm_into_systemexit() self.debug('Running reloading file monitor') @@ -307,8 +308,7 @@ extra_files.extend(self.i18nfiles(cwconfig)) self.install_reloader( self['reload-interval'], extra_files, - filelist_path=os.environ.get( - self._reloader_filelist_environ_key)) + filelist_path=filelist_path) if daemonize: self.daemonize(cwconfig['pid-file'])