Hi,
This is indeed a common pattern, but fluxcapacitor just shows the
obvious race condition.
Instead you should do a proper "wait", that is, for example perform a
blocking read from child socket, and perform a flushed "write" from a
child once socket is set up.
Another option is to perform this synchronization with signals, but
frankly speaking I'm not sure if that will work. It should.
I used to do "wait" after fork in tests myself, but this is just
buggy. Nowadays I mostly do the stdout trick. Once again:
parent:
p = fork_and_exec(child)
port_number = p.stdout.read() # blocking wait on stdout of child
socket.connect("127.0.0.1", port_number) #-> tcp socket from child is ready!
child:
s = socket
s.bind()
s.listen()
print s.getsockname()
for {
s.accept()
}
Does it make sense?
> --
> You received this message because you are subscribed to the Google Groups
> "fluxcapacitor development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
fluxcapacitor-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.