[Twisted-Python] Defer until a server is ready?
For unit testing and other reasons I would like to launch a server in a subprocess, then wait until it is available before running some code that uses it. Is there a standard paradigm for this, e.g. poll until a connection is accepted, or have the server emit some kind of "ready" signal (such as a message to stdout or a UDP packet)? Any advice would be appreciated. A web search didn't turn up anything. In some cases we have used one reactor to run both the server or servers and the client, in which case waiting is trivial. But we have cases where we would much rather run the server in a separate process. -- Russell
On Mon, Oct 21, 2013 at 03:08:56PM -0700, Russell E. Owen wrote:
For unit testing and other reasons I would like to launch a server in a subprocess, then wait until it is available before running some code that uses it. Is there a standard paradigm for this, e.g. poll until a connection is accepted, or have the server emit some kind of "ready" signal (such as a message to stdout or a UDP packet)? Any advice would be appreciated. A web search didn't turn up anything.
Emitting a message on stdout has worked well for me before. You can wait for this in your ProcessProtocol then continue the test case once you receieve it. -E
participants (2)
-
Eric P. Mangold
-
Russell E. Owen