Section 31. In the event that a general contractor or a subcontractor on any construction work is adjudged a bankrupt, or makes a general assignment for the benefit of creditors, or if a receiver is appointed on account of the insolvency of the general contractor or of a subcontractor, at a time when there are sums due or which later become due from the person contracting for the work on account of the work of such general contractor or when there are sums due or which later become due from the general contractor on account of the work of such subcontractor, each person furnishing labor or labor and materials to such general contractor or such subcontractor shall have a lien each in proportion to the amount of his respective claim on all such sums due or which later become due in connection with the particular construction work, provided, that a lien on any such sums arising out of the recording or filing of a document or notice in accordance with the provisions of this chapter or in accordance with any other applicable provisions of the general laws shall have priority over any lien secured pursuant to this section, and provided further, that such lien shall not take effect unless written notice thereof is given to the person owing such sums. Proceedings to enforce a lien secured under this section shall be by a civil action in the superior court within one year after the adjudication of bankruptcy, or the assignment for the benefit of creditors or the appointment of a receiver, and the plaintiff shall bring his action in his own behalf and in behalf of all other persons in interest who shall become parties. All other parties in interest may appear and have their rights determined in such action, and, at any time before entry of final judgment, upon the suggestion of any party in interest that any other person is or may be interested in the action, or of its own motion, the court may summon such person to appear in said cause on or before a day certain or be forever barred from any rights thereunder. The court may in its discretion provide for notice to absent parties in interest. The other provisions of this chapter shall not apply to any such civil action. The provisions of this section shall not apply to any contract with the commonwealth or with any political subdivision thereof or any other public instrumentality.