In real-life manufacturing systems, the presence of defective products in a lot is inevitable. While these products may be just scrapped in the food industry, in high-tech industries where the final product is very expensive, they may be reworked at a cost. A common assumption in the literature is that the inspection time needed to identify defective items is completed when the production process ends. However, the assumption of continuous inspection during production complicates the analysis, making it impractical for most production systems, especially when the production rate is high, and the proportion of defective items is low, making continuous inspection during production very expensive. In addition, such factors as process deterioration or other uncontrollable factors in the production process may interrupt the production of the lot. To address these practical issues, this paper integrates inspection time and the failure of production facilities into an imperfect production inventory model with rework, where the production run time is a decision variable and an inspection process continues even after a production run; the paper demonstrates significant effects on the optimal solutions, with shortages not allowed. Under these assumptions, a mathematical model is derived, and the concavity of the expected total profit function is proved. Optimal policy is obtained by applying the analytic method. Special cases of the model are studied and a numerical example with sensitivity analysis is provided to draw insights. Moreover, this numerical example is used to compare general and special cases.