[core] Execution contexts are now context managers.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor
|
||||
|
||||
from bonobo.constants import BEGIN, END
|
||||
@ -29,19 +28,16 @@ class ExecutorStrategy(Strategy):
|
||||
futures = []
|
||||
|
||||
for plugin_context in context.plugins:
|
||||
|
||||
def _runner(plugin_context=plugin_context):
|
||||
try:
|
||||
plugin_context.start()
|
||||
plugin_context.loop()
|
||||
plugin_context.stop()
|
||||
except Exception as exc:
|
||||
print_error(exc, traceback.format_exc(), context=plugin_context)
|
||||
with plugin_context:
|
||||
try:
|
||||
plugin_context.loop()
|
||||
except Exception as exc:
|
||||
print_error(exc, traceback.format_exc(), context=plugin_context)
|
||||
|
||||
futures.append(executor.submit(_runner))
|
||||
|
||||
for node_context in context.nodes:
|
||||
|
||||
def _runner(node_context=node_context):
|
||||
try:
|
||||
node_context.start()
|
||||
|
||||
Reference in New Issue
Block a user