I have access to a tape archival system on my network. The files stored on this system are quite large, about 700-800MB each, and accessing the system from Windows shows them marked "Archive." When you try to copy, move, or open the file, the tape robot is supposed to move the file off the tape drive onto the network. This can take a while, of course. So, to wake the file, I used a Timer to to open a file for one second.
This should be enough to jog the tape system into moving the file from tape onto hard drive. But it only seems to work intermittently or not at all. Users would launch an unarchive job with my code and SOMETIMES the files would come off quickly, sometimes it took days or never did it at all. Users have much more success using Windows copy/move to force files off the tape system, so I've decided to revisit my script.
The first draft of my script, with threads run in parallel (distilled to essential parts):
from threading import Timer
class WakeFileWorker(QThread):
def init(self, tape_file_path):
super(WakeFileWorker, self).init()
self.tape_file_path = tape_file_path
def wake_file(self):
open(self.tape_file_path)
@pyqtSlot()
def run(self):
Timer(1, self.wake_file).start()
while check_archive_bit(self.tape_file_path): # While the file is unarchived
pass
The attempt by Python to open the file doesn't seem to persist. It seems to work 50% of the time. So I thought, perhaps running a bunch of QRunnables in parallel pinging these files was causing the problem, and maybe I needed to jog the tape system if it was taking too long to move the file from tape. So, I decided to try to wake the files sequentially using QThread instead, and try to open the file again if it's taking too long.
Second draft (run sequentially):
from threading import Timer
class WakeFileWorker(QRunnable):
def init(self, tape_file_path):
super(WakeFileWorker, self).init()
self.tape_file_path = tape_file_path
def wake_file(self):
open(self.tape_file_path)
@pyqtSlot()
def run(self):
Timer(1, self.wake_file).start()
while check_archive_bit(self.tape_file): # While the file is unarchived
if elapsed_time > 180:
Timer(1, self.wake_file).start() # Jog the tape system again
This actually seemed to work WORSE. I left a job using the second code running overnight, and when I came in not a single archived file had moved onto the network. What should I do? Should I try to run the open timer for longer than one second? I do not actually intend to OPEN the file, just to kick the tape system into moving the file to hard drive.