The network adapters (wireless, wired) in an RPi are completely controlled by the operating system. OctoPrint and Python do not have any influence on the state of the adapters, only the drivers and utilities supplied with the operating system.
OctoPi is a repackaging of the lite version of the Raspberry Pi OS (Raspbian) with added packages like OctoPrint. I believe that since "the silent majority" of users aren't having a problem, OctoPi (both 0.17 and 0.18) contain the correct network drivers.
Of course, there could be an obscure bug that is showing itself in the cases reported here. I'd suggest checking the Raspberry Pi forums for similar reports and possible solutions.
Sorry to necro post (not sure if 3d is necro) but if this is a common problem that you are experiencing with your Pi, and you have narrowed your search down the Pi being the issue rather than OctoPrint (which if you're on post is more than likely) then a quick fix can be to set a fixed local IP for your Pi's MAC address.
Should your Pi lose its wireless connection for whatever reason, then you don't need to worry about your home router giving it a new IP address and screwing with any cached DNS addresses. Just a quick and dirty fix, but if you're 3+ hours into a print, it at least lets you finish the print before fixing the underlying issue.
I'm supporting this resurrection! I've the same issue - Pi 4 unresponsive in middle of a 6 hour print, although print proceeding without issue. My router has also stopped showing the connection. I had already set up a static local ip for it and tried connecting via a mac as well as my usual Windows 10, without success. It is a new setup using latest updates, so I obviously can't comment on previous software but I may give @jaduret fix a try
Ip was never an issue, even after running into the problem and I could not connect to Octoprint for the remainder of a print, after restarting the pi (and I then could connect) the IP was always the same.