2016-08-09 16:16:11 +00:00
|
|
|
|
|
|
|
import econtext
|
|
|
|
|
|
|
|
|
2016-08-10 21:13:57 +00:00
|
|
|
def run_with_broker(func, *args, **kwargs):
|
|
|
|
broker = econtext.Broker()
|
|
|
|
try:
|
|
|
|
return func(broker, *args, **kwargs)
|
|
|
|
finally:
|
|
|
|
broker.Finalize()
|
|
|
|
|
|
|
|
|
2016-08-09 16:16:11 +00:00
|
|
|
def with_broker(func):
|
|
|
|
def wrapper(*args, **kwargs):
|
2016-08-10 21:13:57 +00:00
|
|
|
return run_with_broker(*args, **kwargs)
|
2016-08-09 16:16:11 +00:00
|
|
|
wrapper.func_name = func.func_name
|
|
|
|
return wrapper
|