Is the wait time at the start of Device.open() necessary?

Asked by Gabriel Carrillo

I'm not sure if this is the right place to ask these questions but I also wouldn't say it's a bug. I was having long wait times for a simple cli script and I ended up narrowing it down to the first line of the Device.open() function, which adds 5 seconds of wait time at the start for seemingly no reason, so in the best case scenario getting the device info for a single connected device takes 5 seconds. The rest of the code only seems to call sleep() to add delays after exceptions, which makes more sense to me than doing it preemptively.

Is there a point to calling sleep at the start of the function? For a single device 5 seconds might not be that much, but when running cli.py(ebook-device), the main function will call open() for every connected device.

The relevant code in src/calibre/devices/usbms/device.py looks like this:

class Device(DeviceConfig, DevicePlugin):
    ...
    def open(self, connected_device, library_uuid):
        time.sleep(5)
        self._main_prefix = self._card_a_prefix = self._card_b_prefix = None
        self.device_being_opened = connected_device
        ...

I commented the first line of the function and everything seems to work fine, but I wanted to know if there's reason not to do so. At the very least, I'd like to know if the delay could be shorter.

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu calibre Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.