Package osh :: Module oshthread
[frames] | no frames]

Source Code for Module osh.oshthread

 1  # osh 
 2  # Copyright (C) Jack Orenstein <jao@geophile.com> 
 3  # 
 4  # This program is free software; you can redistribute it and/or modify 
 5  # it under the terms of the GNU General Public License as published by 
 6  # the Free Software Foundation; either version 2 of the License, or 
 7  # (at your option) any later version. 
 8  # 
 9  # This program is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
12  # GNU General Public License for more details. 
13  # 
14  # You should have received a copy of the GNU General Public License 
15  # along with this program; if not, write to the Free Software 
16  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
17   
18  import sys 
19  import threading 
20   
21  # "Private" name (with leading underscore) so that epydoc doesn't document the class 
22 -class _OshThread(threading.Thread):
23 24 _owner = None 25 _pipeline = None 26 _thread_state = None 27 _terminating_exception = None 28
29 - def __init__(self, owner, thread_state, pipeline):
30 threading.Thread.__init__(self) 31 self._owner = owner 32 self._pipeline = pipeline 33 self._thread_state = thread_state 34 pipeline.set_thread_state(thread_state)
35
36 - def __repr__(self):
37 return 'oshthread(%s)' % self._thread_state
38 39 state = property(lambda self: self._thread_state) 40 pipeline = property(lambda self: self._pipeline) 41 terminating_exception = property(lambda self: self._terminating_exception) 42
43 - def run(self):
44 try: 45 # Don't call self._pipeline.setup(): Done by _Fork.execute 46 self._pipeline.execute() 47 except Exception, e: 48 self._terminating_exception = e
49