Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2013 22:46
Show Gist options
  • Save anonymous/4990908 to your computer and use it in GitHub Desktop.
Save anonymous/4990908 to your computer and use it in GitHub Desktop.
diff --git a/epu/provisioner/leader.py b/epu/provisioner/leader.py
index c1808f8..ad59b00 100644
--- a/epu/provisioner/leader.py
+++ b/epu/provisioner/leader.py
@@ -139,16 +139,16 @@ class ProvisionerLeader(object):
self.core.terminate_all()
if self.terminator_thread is None:
- self.terminator_thread = tevent.spawn(self.run_terminator, fail_fast=True)
+ self.terminator_thread = tevent.spawn(self.run_terminator, _fail_fast=True)
if self.site_query_thread is None:
- self.site_query_thread = tevent.spawn(self.run_site_query_thread, fail_fast=True)
+ self.site_query_thread = tevent.spawn(self.run_site_query_thread, _fail_fast=True)
if self.context_query_thread is None:
- self.context_query_thread = tevent.spawn(self.run_context_query_thread, fail_fast=True)
+ self.context_query_thread = tevent.spawn(self.run_context_query_thread, _fail_fast=True)
if self.record_reaper_thread is None:
- self.record_reaper_thread = tevent.spawn(self.run_record_reaper_thread, fail_fast=True)
+ self.record_reaper_thread = tevent.spawn(self.run_record_reaper_thread, _fail_fast=True)
with self.condition:
if self.is_leader:
diff --git a/epu/test/test_tevent.py b/epu/test/test_tevent.py
index b84c4ed..de1c3c6 100644
--- a/epu/test/test_tevent.py
+++ b/epu/test/test_tevent.py
@@ -31,5 +31,5 @@ def test_fail_fast():
def raises_typerror():
raise TypeError("This thread failed!")
- tevent.spawn(raises_typerror, fail_fast=True, exit=mock_exit)
+ tevent.spawn(raises_typerror, _fail_fast=True, _exit=mock_exit)
diff --git a/epu/tevent.py b/epu/tevent.py
index 4397607..1be0b6e 100644
--- a/epu/tevent.py
+++ b/epu/tevent.py
@@ -11,7 +11,8 @@ Helper functions for working with stdlib threading library
Inspired by the gevent api
"""
-def spawn(func, fail_fast=False, exit=None, *args, **kwargs):
+
+def spawn(func, *args, **kwargs):
"""spawn - spawn and start a thread
@param func - function to run in the thread
@@ -25,7 +26,19 @@ def spawn(func, fail_fast=False, exit=None, *args, **kwargs):
else:
name = func.__name__
- if fail_fast == True:
+ if '_fail_fast' in kwargs:
+ fail_fast = kwargs['_fail_fast']
+ del(kwargs['_fail_fast'])
+ else:
+ fail_fast = None
+
+ if '_exit' in kwargs:
+ exit = kwargs['_exit']
+ del(kwargs['_exit'])
+ else:
+ exit = None
+
+ if fail_fast is True:
def critical_wrapper():
try:
func()
@@ -58,8 +71,8 @@ class Pool(ThreadPool):
"""
def __init__(self, *args, **kwargs):
- """We need to patch threading to support ThreadPool being run in
- child threads.
+ """We need to patch threading to support ThreadPool being run in
+ child threads.
Shouldn't be necessary when http://bugs.python.org/issue10015 is fixed
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment