On Feb 28, 2017, at 8:11 AM, Роман Мещеряков <romanmescheryakov@yandex.ru> wrote:Hello everyone,today I tried restarting twisted service using sys.execv, and it fails with the following message:> 2017-02-28T18:39:47+0300 [ready_to_setup#debug] Before os.execv: sys.executable is /usr/bin/python and sys.argv are ['/usr/local/bin/twistd', '-ny', 'master_player.tac']> Another twistd server is running, PID 1939> This could either be a previously started instance of your application or a> different application entirely. To start a new one, either run it in some other> directory, or use the --pidfile and --logfile parameters to avoid clashes.My service is started in the following way:PYTHONPATH=. twistd -ny master_player.tac(i.e. without daemonization)Code to restart is:> d = task.deferLater(self._reactor, seconds,> shared_code.restart_script, self._log, self._reactor)> # _restart_script_done should never be called> d.addCallback(self._restart_script_done).addErrback(self._restart_script_failure)where shared_code.restart_script is:> def restart_script(logger, reactor):> logger.info("Restarting script...")> reactor.stop()> sys.stdout.flush()> #TODO: force logging system to flush all log files> logger.debug("Before os.execv: sys.executable is {sysexec} and sys.argv are {argv}",> sysexec = sys.executable, argv = sys.argv)> os.execv(sys.executable, [sys.executable] + sys.argv)Could someone explain to me why does the "Another twistd server is running" error occur and how can I avoid it?