Permalink
Browse files

Removed never really working `timeout` and `with_timeout` functions

  • Loading branch information...
1 parent f8f21fc commit e4cdf1e1493343fff913f9f4ade2e0122883d98a @tailhook committed Feb 7, 2012
Showing with 1 addition and 35 deletions.
  1. +1 −35 zorro/__init__.py
View
36 zorro/__init__.py
@@ -7,44 +7,10 @@
'Hub',
'gethub',
'sleep',
- 'timeout',
- 'with_timeout',
- 'TimeoutException',
'Future',
'Condition',
+ 'Lock',
]
def sleep(value):
gethub().do_sleep(value)
-
-class TimeoutException(Exception):
- """Raised when you use timeout context manager and process timed out"""
-
-class FinishedException(Exception):
- """Internal exception for timeout context manager"""
-
-@contextmanager
-def timeout(value, description="Process timed out"):
- """Context manager to limit execution time of code path to time in seconds
- """
- def _timeout():
- try:
- sleep(value)
- except FinishedException:
- pass
- else:
- raise TimeoutException(description)
- let = gethub().do_spawn(timeout)
- yield let
- let.throw(FinishedException())
-
-def with_timeout(value, description="Process timed out"):
- """Decorator which limits execution time of function call to time in seconds
- """
- def wrapper(fun):
- @wraps(fun)
- def wrapping(*a, **k):
- with timeout(value, description):
- return fun(*a, **kw)
- return wrapping
- return wrapper

0 comments on commit e4cdf1e

Please sign in to comment.