Francesco Romani has submitted this change and it was merged.

Change subject: concurrent: Introduce concurrent.thread() utility
......................................................................


concurrent: Introduce concurrent.thread() utility

We are repeating this boilerplate code everywhere:

    def __init__(self):
        self._thread = threading.Thread(target=self._run, name="foobar")
        self._thread.daemon = True

    @utils.traceback(on=log.name)
    def _run(self):
        # stuff to run in thread

This boilerplate is going to become worse since we want to set thread
system name in the thread target method.

This patch introduces concurrent.thread() utility function, eliminating
the boilerplate:

    def __init__(self):
        self._thread = concurrent.thread(self._run, name="foobar",
                                         logger=self.log.name)

    def _run(self):
        # stuff to run in thread

This utility will be extended later to set system thread name based on
Python thread name.

Change-Id: I92bbf3ea55365e110038d5d50f200d5fc8a6a06f
Signed-off-by: Nir Soffer <nsof...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/1269424
Reviewed-on: https://gerrit.ovirt.org/44894
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <from...@redhat.com>
Reviewed-by: Piotr Kliczewski <piotr.kliczew...@gmail.com>
Reviewed-on: https://gerrit.ovirt.org/52624
Tested-by: Francesco Romani <from...@redhat.com>
---
M lib/vdsm/concurrent.py
M tests/concurrentTests.py
2 files changed, 72 insertions(+), 0 deletions(-)

Approvals:
  Piotr Kliczewski: Looks good to me, but someone else must approve
  Nir Soffer: Looks good to me, but someone else must approve
  Jenkins CI: Passed CI tests
  Francesco Romani: Verified; Looks good to me, approved



-- 
To view, visit https://gerrit.ovirt.org/52624
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I92bbf3ea55365e110038d5d50f200d5fc8a6a06f
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com>
Gerrit-Reviewer: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsof...@redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourf...@redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczew...@gmail.com>
Gerrit-Reviewer: gerrit-hooks <automat...@ovirt.org>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to