Depends. If you are a Canadian citizen, then yes. If you are a PR, then no. A few months is too long a visit and you must be living in Canada while you sponsor your spouse. You should keep your trip under three weeks in length.
You're a Permanent Resident, right? You need to show that you reside in Canada to be eligible.
A short trip shouldn't be an issue, but if you file an application and then leave the country for months, it may lead to your application being denied.