That is what the automatic stay does--it provides the pause to make sure nobody gets to jump ahead in line. As long as the stay remains in place, the landlord (or any other creditor) is forbidden from taking steps to evict a debtor. But it is possible to get relief from the stay if you can demonstrate that you would not be jumping ahead in line, and often relief from stay motions can be heard quickly. If the debtor needs the stay in order to reorganize (the theory being that it is better to have a bigger pie) then the debtor can apply for an extension, but only if it provides "adequate protection," which generally means paying according to the terms of the contract, or supplying additional collateral, or some such.
Timing is important. Once you file, all legal actions against you cease, and that is a very powerful tool. Unfortunately, you can only use that tool once. (Well, if you are a human individual, you get another chance years later.)
That is a very brief sketch. I haven't been a lawyer for years. You can ask a real bankruptcy lawyer for details.