'äžºtaskæ°å»ºäžäžªåå°äžèœœçº¿çš, å¹¶åŒå§äžèœœ.'

def start_worker(self, row):

    def on_worker_started(worker, fs_id):
        pass
    def on_worker_received(worker, fs_id, received, received_total):
        GLib.idle_add(do_worker_received, fs_id, received, received_total)
    def do_worker_received(fs_id, received, received_total):
        self.download_speed_add(received)
        row = None
        if (fs_id in self.workers):
            row = self.workers[fs_id][1]
        else:
            row = self.get_row_by_fsid(fs_id)
        if (not row):
            return
        row[CURRSIZE_COL] = received_total
        curr_size = util.get_human_size(row[CURRSIZE_COL], False)[0]
        total_size = util.get_human_size(row[SIZE_COL])[0]
        row[PERCENT_COL] = int(((row[CURRSIZE_COL] / row[SIZE_COL]) * 100))
        row[HUMANSIZE_COL] = '{0}    /    {1}'.format(curr_size, total_size)
        self.update_task_db(row)
    def on_worker_downloaded(worker, fs_id):
        GLib.idle_add(do_worker_downloaded, fs_id)
    def do_worker_downloaded(fs_id):
        row = None
        if (fs_id in self.workers):
            row = self.workers[fs_id][1]
        else:
            row = self.get_row_by_fsid(fs_id)
        if (not row):
            return
        row[CURRSIZE_COL] = row[SIZE_COL]
        row[STATE_COL] = State.FINISHED
        row[PERCENT_COL] = 100
        total_size = util.get_human_size(row[SIZE_COL])[0]
        row[HUMANSIZE_COL] = '{0}    /    {1}'.format(total_size, total_size)
        row[STATENAME_COL] = StateNames[State.FINISHED]
        self.update_task_db(row)
        self.check_commit(force=True)
        self.workers.pop(row[FSID_COL], None)
        self.app.toast(_('{0}    downloaded'.format(row[NAME_COL])))
        self.launch_app(fs_id)
        self.scan_tasks()
    def on_worker_network_error(worker, fs_id):
        GLib.idle_add(do_worker_network_error, fs_id)
    def do_worker_network_error(fs_id):
        row = self.workers.get(fs_id, None)
        if row:
            row = row[1]
        else:
            row = self.get_row_by_fsid(fs_id)
            if (not row):
                return
        row[STATE_COL] = State.ERROR
        row[STATENAME_COL] = StateNames[State.ERROR]
        self.update_task_db(row)
        self.remove_worker(row[FSID_COL], stop=False)
        if self.app.profile['retries-each']:
            GLib.timeout_add((self.app.profile['retries-each'] * 60000), self.restart_task, row)
        else:
            self.app.toast(_('Error    occurs    will    downloading    {0}').format(row[NAME_COL]))
        self.scan_tasks()
    def do_worker_disk_error(fs_id, tmp_filepath):
        self.app.toast(_('Disk    Error:    failed    to    read/write    {0}').format(tmp_filepath))
    def on_worker_disk_error(worker, fs_id, tmp_filepath):
        GLib.idle_add(do_worker_disk_error, fs_id, tmp_filepath)
    if ((not row) or (row[FSID_COL] in self.workers)):
        return
    row[STATE_COL] = State.DOWNLOADING
    row[STATENAME_COL] = StateNames[State.DOWNLOADING]
    worker = Downloader(self, row)
    self.workers[row[FSID_COL]] = (worker, row)
    worker.connect('started', on_worker_started)
    worker.connect('received', on_worker_received)
    worker.connect('downloaded', on_worker_downloaded)
    worker.connect('network-error', on_worker_network_error)
    worker.connect('disk-error', on_worker_disk_error)
    worker.start()
