Of course, perfect is not only largely unlikely, but totally subjective. At any rate, there I am working on the play, for weeks, months, or even a year or more. The fun, excitement, and raw inspiration seem to have disappeared. If it's just a matter of discipline, that's one thing. But sometimes the play just doesn't want to be written at that time.
First thing is to take stock of a few fundamentals.
I maintain a pretty good rapport with a couple of my publishers, to the point where I can call them and bounce ideas off them before beginning a new work. Then, if it's something that they've shown interest in, at least I have a better chance that the piece will be sold. But even then, it's no guarantee. The piece that sounds so promising to them at one point emerges to be something else, something that they just don't believe works for their audiences. Then the playwright has to weigh that against what marketability the play holds.