Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNHRONIZE does notreuse engine internals #56

Open
poinot opened this issue Aug 24, 2017 · 1 comment
Open

SYNHRONIZE does notreuse engine internals #56

poinot opened this issue Aug 24, 2017 · 1 comment

Comments

@poinot
Copy link

poinot commented Aug 24, 2017

The SYNCHRONIZE pattern runs concurrent callbacks using threads.
However, the call does not fire the before_each_callback and after_each_callback wrappers.

Proposed changed in workflow/pattern/controlflow.py (_synchronize)

        for func in args[0:-1]:
            if isinstance(func, list) or isinstance(func, tuple):
                new_eng = eng.duplicate()
                new_eng.setWorkflow(func)
                queue.put(lambda: new_eng.process([obj]))
            else:
                def t_func(obj,eng):
                    ecb=eng.processing_factory.action_mapper
                    ecb.before_each_callback(eng,func,obj)
                    eng.execute_callback(func,obj)
                    ecb.after_each_callback(eng,func,obj)
                queue.put(lambda t_func=t_func : t_func(obj, eng))
@lucasfcardozo
Copy link
Contributor

lucasfcardozo commented Apr 18, 2019

I had the same problem. My solution was to add a task_done in run() method of the MySpecialThread class (workflow/pattern/controlflow.py).

class MySpecialThread(threading.Thread):

    def __init__(self, itemq, *args, **kwargs):
        threading.Thread.__init__(self, *args, **kwargs)
        self.itemq = itemq

    def run(self):
        call = self.itemq.get()
        call()
        self.itemq.task_done()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants