Perhaps the best science-based answer can be found here Survival in Space Unprotected Is Possible--Briefly All quotes are from this article.
In reality, however, animal experiments and human accidents have shown that people can likely survive exposure to vacuum conditions for at least a couple of minutes. Not that you would remain conscious long enough to rescue yourself, but if your predicament was accidental, there could be time for fellow crew members to rescue and repressurize you with few ill effects.
and
But death is not instantaneous. For example, one 1965 study by researchers at the Brooks Air Force Base in Texas showed that dogs exposed to near vacuum—one three-hundred-eightieth of atmospheric pressure at sea level—for up to 90 seconds always survived. ... But after slight repressurization the dogs shrank back down, began to breathe, and after 10 to 15 minutes at sea level pressure, they managed to walk, though it took a few more minutes for their apparent blindness to wear off.
With the caveat
Water and dissolved gas in the blood forms bubbles in the major veins, which travel throughout the circulatory system and block blood flow. After about one minute circulation effectively stops. 978
The lack of oxygen to the brain renders you unconscious in less than 15 seconds, eventually killing you. "When the pressure gets very low there is just not enough oxygen. That is really the first and most important concern," <PERSON> says.
It's not how much oxygen is in the body (thus holding your breath is irrelevant but dangerous) but how it is ported to the brain.
Chimpanzees can withstand even longer exposures. In a pair of papers from NASA in 1965 and 1967, researchers found that chimpanzees could survive up to 3.5 minutes in near-vacuum conditions with no apparent cognitive defects, as measured by complex tasks months later.
and
For example, in 1965 a technician inside a vacuum chamber at Johnson Space Center in Houston accidentally depressurized his space suit by disrupting a hose. After 12 to 15 seconds he lost consciousness. He regained it at 27 seconds, after his suit was repressurized to about half that of sea level. The man reported that his last memory before blacking out was of the moisture on his tongue beginning to boil as well as a loss of taste sensation that lingered for four days following the accident, but he was otherwise unharmed.
So, extrapolated, it is reasonable to assume that perhaps ten seconds of exposure, and twenty seconds of recovery could give the results you are after. 978