We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We very often need to do the following:
send_event(e) # notify start ... e.close() send_event(e) # notify end
We could factorize such code in EventManager, e.g. with:
+++ b/e3/event/backends/base.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function import abc +import contextlib import uuid import e3.env @@ -79,3 +80,13 @@ class EventManager(object): def Event(self): """Return the Event class used by this EventManager.""" pass # all: no cover + + @contextlib.contextmanager + def with_event(self, *args, **kwargs): + e = self.Event(*args, **kwargs) + try: + self.send_event(e) + yield e + finally: + e.close() + self.send_event(e)
Code not tested!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
We very often need to do the following:
We could factorize such code in EventManager, e.g. with:
Code not tested!
The text was updated successfully, but these errors were encountered: