Revision: d634da6cdfcd
Author: Mikko Korpela <[email protected]>
Date: Wed Jan 11 06:33:21 2012
Log: Timeout cleanup.
http://code.google.com/p/robotframework/source/detail?r=d634da6cdfcd
Modified:
/src/robot/running/timeouts/__init__.py
/src/robot/running/timeouts/timeoutsignaling.py
/src/robot/running/timeouts/timeoutthread.py
/src/robot/running/timeouts/timeoutwin.py
=======================================
--- /src/robot/running/timeouts/__init__.py Wed Jan 11 06:11:20 2012
+++ /src/robot/running/timeouts/__init__.py Wed Jan 11 06:33:21 2012
@@ -16,20 +16,21 @@
import os
import time
+from robot import utils
+from robot.errors import TimeoutError, DataError, FrameworkError
+
if sys.platform == 'cli':
- from timeoutthread import Timeout
+ from .timeoutthread import Timeout
elif os.name == 'nt':
- from timeoutwin import Timeout
+ from .timeoutwin import Timeout
else:
try:
# python 2.6 or newer in *nix or mac
- from timeoutsignaling import Timeout
+ from .timeoutsignaling import Timeout
except ImportError:
# python < 2.6 and jython don't have complete signal module
- from timeoutthread import Timeout
-
-from robot import utils
-from robot.errors import TimeoutError, DataError, FrameworkError
+ from .timeoutthread import Timeout
+
class _Timeout(object):
=======================================
--- /src/robot/running/timeouts/timeoutsignaling.py Wed Dec 14 06:14:08 2011
+++ /src/robot/running/timeouts/timeoutsignaling.py Wed Jan 11 06:33:21 2012
@@ -34,7 +34,7 @@
signal(SIGALRM, self._raise_timeout_error)
setitimer(ITIMER_REAL, self._timeout)
- def _raise_timeout_error(self, *args):
+ def _raise_timeout_error(self, signum, frame):
raise TimeoutError(self._error)
def _stop_timer(self):
=======================================
--- /src/robot/running/timeouts/timeoutthread.py Wed Jan 11 06:11:20 2012
+++ /src/robot/running/timeouts/timeoutthread.py Wed Jan 11 06:33:21 2012
@@ -12,19 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from robot.errors import TimeoutError
-
import sys
from threading import Event
+from robot.errors import TimeoutError
+
if sys.platform.startswith('java'):
from java.lang import Thread, Runnable
else:
- from stoppablethread import Thread
+ from .stoppablethread import Thread
Runnable = object
+
TIMEOUT_THREAD_NAME = 'RobotFrameworkTimeoutThread'
+
class ThreadedRunner(Runnable):
def __init__(self, runnable):
=======================================
--- /src/robot/running/timeouts/timeoutwin.py Wed Dec 14 06:14:08 2011
+++ /src/robot/running/timeouts/timeoutwin.py Wed Jan 11 06:33:21 2012
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import with_statement
import ctypes
import thread
import time
@@ -32,16 +31,19 @@
def _create_timeout_error_class(self, timeout_error):
return type(TimeoutError.__name__,
(TimeoutError,),
- {'__unicode__': lambda s: timeout_error})
+ {'__unicode__': lambda self: timeout_error})
def execute(self, runnable):
- with self:
+ self._start_timer()
+ try:
return runnable()
-
- def __enter__(self):
+ finally:
+ self._stop_timer()
+
+ def _start_timer(self):
self._timer.start()
- def __exit__(self, *args):
+ def _stop_timer(self):
self._timer.cancel()
# In case timeout has occurred but the exception has not yet been
# thrown we need to do this to ensure that the exception