を
はパイロに見ていたし、彼らが自分のdaemonzingモジュールを含んでいるようです。私はコードを改善するための提案を感謝します。
def start_server():
pyrodaemon = Pyro.core.Daemon()
#setup daemon and nameserver
#Don't want to close the pyro socket
#Need to remove SIGTERM map so Processing doesn't kill the subprocess
#Need to explicitly detach for some reason I don't understand
with daemon.DaemonContext(files_preserve=[pyrodaemon.sock],signal_map={signal.SIGTERM:None},detach_process=True):
while running:
pyrodaemon.handleRequests(timeout=1.0)
#when finished, clean up
pyrodaemon.shutdown()
def main():
p = Process(target=start_server)
p.daemon=True # Need to inform Process that this should run as a daemon
p.start()
time.sleep(3.0) # Important when running this program stand alone: Must wait long enough for start_server to get into the daemon context before the main program exits or Process will take down the subprocess before it detaches
do_other_stuff_not_in_the_daemon()
ありがとうございます。最近私自身がその解決策を見いだしたので、私は同意します。しかし、python-daemonは、プログラムがデーモンとして起動し、決して戻ってこない1つの関数を持つより標準的なパラダイムをターゲットにしているようです。 )(daemon.DaemonContextで :私はの線に沿って何かをしたいと思いますcontinue_with_this_function_after_daemon_has_launched some_daemon_loop() () 私はどんな提案を感謝しています。 – glenn
私は以前パイロを見ていませんでした。彼らのコードを大まかに見ると、 "デーモン"クラスはスレッドディスパッチャのようなもので、別のプロセスではありません。コード内でどこでフォークするのか分かりません。 Pyroには、デーモンの実際のデーモン機能のためのモジュールが含まれています。 – JimB