Dan Kenigsberg 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 <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/44894
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <[email protected]>
Reviewed-by: Piotr Kliczewski <[email protected]>
---
M lib/vdsm/concurrent.py
M tests/concurrentTests.py
2 files changed, 72 insertions(+), 0 deletions(-)

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



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

Gerrit-MessageType: merged
Gerrit-Change-Id: I92bbf3ea55365e110038d5d50f200d5fc8a6a06f
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Piotr Kliczewski <[email protected]>
Gerrit-Reviewer: [email protected]
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to