<div>Then the next question is: how to run my .tac file with twist? I don't see option like '-y' in it's --help output.</div><div> </div><div>-- </div><div>Kind regards, Roman Mescheryakov</div><div> </div><div> </div><div> </div><div>01.03.2017, 05:54, "Glyph Lefkowitz" <glyph@twistedmatrix.com>:</div><blockquote type="cite"><div> <div><blockquote type="cite"><div>On Feb 28, 2017, at 8:11 AM, Роман Мещеряков <<a href="mailto:romanmescheryakov@yandex.ru">romanmescheryakov@yandex.ru</a>> wrote:</div> <div><div>Hello everyone,</div><div>today I tried restarting twisted service using sys.execv, and it fails with the following message:</div><div> </div><div><div><div>> <span>2017-02-28</span>T18: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']</div><div>> Another twistd server is running, PID 1939</div><div> </div><div>> This could either be a previously started instance of your application or a</div><div>> different application entirely. To start a new one, either run it in some other</div><div>> directory, or use the --pidfile and --logfile parameters to avoid clashes.</div></div></div><div> </div><div>My service is started in the following way:</div><div> </div><div>PYTHONPATH=. twistd -ny master_player.tac</div><div> </div><div>(i.e. without daemonization)</div><div>Code to restart is:</div><div> </div><div><div><div>> d = task.deferLater(self._reactor, seconds,</div><div>>                     shared_code.restart_script, self._log, self._reactor)</div><div>> # _restart_script_done should never be called</div><div>> d.addCallback(self._restart_script_done).addErrback(self._restart_script_failure)</div><div> </div><div>where shared_code.restart_script is:</div><div> </div><div>> def restart_script(logger, reactor):</div><div>>     <a href="http://logger.info/">logger.info</a>("Restarting script...")</div><div>>     reactor.stop()</div><div>>     sys.stdout.flush()</div><div>>     #TODO: force logging system to flush all log files</div><div>>     logger.debug("Before os.execv: sys.executable is {sysexec} and sys.argv are {argv}",</div><div>>                 sysexec = sys.executable, argv = sys.argv)</div><div>>     os.execv(sys.executable, [sys.executable] + sys.argv)</div><div> </div><div>Could someone explain to me why does the "Another twistd server is running" error occur and how can I avoid it?</div></div></div></div></blockquote><div> </div><div>twistd writes a .pid file and then attempts to check whether another process on the system has the same PID contained in that file while starting up, to avoid conflicts.</div><div> </div><div>Yours is an odd case, because the process with that process-ID is the _current_ process, and perhaps the check ought to even be modified to account for this.</div><div> </div><div>Two other options you have are:</div><div> </div><div><ol><li>switch to `twist`, which doesn't write a pidfile</li><li>use the option "--pidfile ''" to disable writing a pidfile.</li></ol><div> </div><div>I strongly suggest the first option :).</div><div> </div><div>-glyph</div></div></div></div>,<p>_______________________________________________<br />Twisted-Python mailing list<br /><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br /><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a></p></blockquote>