~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/utils/ipc/simple_worker.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        self.listener = listener
59
59
        self.worker = worker
60
60
        self.conn = None
 
61
        self.kill_thread = t = Thread(target=self.worker.kill)
 
62
        t.daemon = True
61
63
 
62
64
    def __call__(self, module, func, *args, **kwargs):
63
65
        if self.conn is None:
73
75
            traceback.print_exc()
74
76
        finally:
75
77
            self.conn = None
76
 
            t = Thread(target=self.worker.kill)
77
 
            t.daemon = True
78
78
            try:
79
79
                os.remove(self.worker.log_path)
80
80
            except:
81
81
                pass
82
 
            t.start()
 
82
            self.kill_thread.start()
 
83
 
 
84
    def is_alive(self):
 
85
        return self.worker.is_alive or self.kill_thread.is_alive()
83
86
 
84
87
def communicate(ans, worker, listener, args, timeout=300, heartbeat=None,
85
88
        abort=None):