diff --git a/src/socketify/cli.py b/src/socketify/cli.py index 50afa4f..1fb2077 100644 --- a/src/socketify/cli.py +++ b/src/socketify/cli.py @@ -331,7 +331,7 @@ def _execute(args): ) # file watcher - def launch_with_file_probe(run_method, user_module_function, poll_frequency=4): + def launch_with_file_probe(run_method, user_module_function, poll_frequency=3): import importlib.util directory = os.path.dirname(importlib.util.find_spec(user_module_function.__module__).origin) directory_glob = os.path.join(directory, '**') @@ -375,8 +375,8 @@ def _execute(args): """ Get files and their modified time and compare with previous times. Restart the server if it has changed """ new_files = get_files() - if len(new_files) > 180: - print(f"{len(new_files)} files being watched", new_files) + if len(new_files) > 200: + print(f"Warning {len(new_files)} files being watched, --reload-ignore-patterns can be used to reduce number") if prev_files is not None and new_files != prev_files: """ @@ -385,8 +385,7 @@ def _execute(args): """ print('Reloading...') reload_state.reload_pending = True #signal for Exeute to know whether it is a real external SIGTERM or our own - import signal - signal.raise_signal(signal.SIGTERM) # sigterm works on windows and posix + os.kill(os.getpid(), signal.SIGTERM) # sigterm works on windows and posix. raise_signal doesnt seem to send to right proces return new_files diff --git a/src/socketify/socketify.py b/src/socketify/socketify.py index 71770b4..de71ef2 100644 --- a/src/socketify/socketify.py +++ b/src/socketify/socketify.py @@ -3384,7 +3384,7 @@ class App: request to reload the process """ self.close() raise SystemExit('reload') - + signal.signal(signal.SIGTERM, reload_signal_handler) # used by --reload in cli.py to reload process self.loop.run()