Escapism is the Flight in The Five Fs. If I can’t take my body somewhere away from this Pain, I can at least take my mind.
Distraction creates relief from unpleasant realities.
Like most Maladaptive Coping Mechanisms, it doesn’t do much to actually remove the source of the pain in the first place.
To qualify, it just needs to be complex enough to take up your limited working memory. With your focus elsewhere, you temporarily forget the pain exists.
Like most ways of Dealing With Pain, the quicker the better. Pain Demands An Immediate Solution.
So, the quick-hit of Outrage Porn on social media or Actual Porn are common solutions.
Going inward is also common. Daydreaming complex scenarios (like rehearsing arguments in the shower). Focusing on a hobby project you never intend to Publish.
So long as it offers enough depth that your mind can focus on Building The Model, it will force you to forget whatever was causing you pain earlier.