)]}'
{"nova/tests/unit/virt/libvirt/volume/test_quobyte.py":[{"author":{"_account_id":13915,"name":"Silvan Kaiser","email":"silvan@quobyte.com","username":"kaisers"},"change_message_id":"03549add1d981f5da76d0dbf90ba3873ae176236","unresolved":false,"context_lines":[{"line_number":35,"context_line":""},{"line_number":36,"context_line":"@ddt.ddt"},{"line_number":37,"context_line":"@mock.patch.object(quobyte, \u0027found_sysd\u0027, False)"},{"line_number":38,"context_line":"@mock.patch.object(quobyte, \u0027sysd_checked\u0027, False)"},{"line_number":39,"context_line":"class QuobyteTestCase(test.NoDBTestCase):"},{"line_number":40,"context_line":"    \"\"\"Tests the nova.virt.libvirt.volume.quobyte module utilities.\"\"\""},{"line_number":41,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"5fc1f717_c4ce97b3","line":38,"updated":"2019-04-02 09:00:29.000000000","message":"Pls drop these mocks","commit_id":"e660c6646b8f8dd02c0b64b20b6c2db630969315"},{"author":{"_account_id":29525,"name":"Artem Vasilyev","email":"artem.v.vasilyev@gmail.com","username":"artem.v.vasilyev"},"change_message_id":"5ceb82f99b3b2bf22baadc64ffa1c7d1582cdb25","unresolved":false,"context_lines":[{"line_number":35,"context_line":""},{"line_number":36,"context_line":"@ddt.ddt"},{"line_number":37,"context_line":"@mock.patch.object(quobyte, \u0027found_sysd\u0027, False)"},{"line_number":38,"context_line":"@mock.patch.object(quobyte, \u0027sysd_checked\u0027, False)"},{"line_number":39,"context_line":"class QuobyteTestCase(test.NoDBTestCase):"},{"line_number":40,"context_line":"    \"\"\"Tests the nova.virt.libvirt.volume.quobyte module utilities.\"\"\""},{"line_number":41,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"5fc1f717_452f00a7","line":38,"in_reply_to":"5fc1f717_c4ce97b3","updated":"2019-04-02 12:39:16.000000000","message":"Done","commit_id":"e660c6646b8f8dd02c0b64b20b6c2db630969315"}],"nova/virt/libvirt/volume/quobyte.py":[{"author":{"_account_id":9555,"name":"Matthew Booth","email":"mbooth@redhat.com","username":"MatthewBooth"},"change_message_id":"c081848f47c870dcac6e60b499cca7a170ea587f","unresolved":false,"context_lines":[{"line_number":49,"context_line":"    \"\"\"Checks if the host is running systemd\"\"\""},{"line_number":50,"context_line":"    global _is_systemd"},{"line_number":51,"context_line":""},{"line_number":52,"context_line":"    if _is_systemd is not None:"},{"line_number":53,"context_line":"        return _is_systemd"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"    _is_systemd \u003d False"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"    if psutil.Process(1).name() \u003d\u003d \"systemd\" or os.path.exists("},{"line_number":58,"context_line":"            SYSTEMCTL_CHECK_PATH):"},{"line_number":59,"context_line":"        # NOTE(kaisers): exit code might be \u003e1 in theory but in practice this"},{"line_number":60,"context_line":"        # is hard coded to 1. Due to backwards compatibility and systemd"},{"line_number":61,"context_line":"        # CODING_STYLE this is unlikely to change."},{"line_number":62,"context_line":"        sysdout, sysderr \u003d processutils.execute(\"systemctl\","},{"line_number":63,"context_line":"                                                \"is-system-running\","},{"line_number":64,"context_line":"                                                check_exit_code\u003d[0, 1])"},{"line_number":65,"context_line":"        for state in VALID_SYSD_STATES:"},{"line_number":66,"context_line":"            if state \u003d\u003d sysdout.strip():"},{"line_number":67,"context_line":"                _is_systemd \u003d True"},{"line_number":68,"context_line":"                break"},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"    return _is_systemd"},{"line_number":71,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"5fc1f717_7f396e3d","line":68,"range":{"start_line":52,"start_character":0,"end_line":68,"end_character":21},"updated":"2019-04-02 10:01:37.000000000","message":"You need a lock here, although you can avoid this by setting _is_systemd once at the end and using a local variable before that. Not using a lock risks running this twice initially. As that\u0027s not really a problem, I suggest this is the best way to go here.\n\nIf you don\u0027t do either, there\u0027s a short window where a second concurrent caller can get an incorrect return of False from this function on a system which supports systemd.","commit_id":"e660c6646b8f8dd02c0b64b20b6c2db630969315"},{"author":{"_account_id":29525,"name":"Artem Vasilyev","email":"artem.v.vasilyev@gmail.com","username":"artem.v.vasilyev"},"change_message_id":"5ceb82f99b3b2bf22baadc64ffa1c7d1582cdb25","unresolved":false,"context_lines":[{"line_number":49,"context_line":"    \"\"\"Checks if the host is running systemd\"\"\""},{"line_number":50,"context_line":"    global _is_systemd"},{"line_number":51,"context_line":""},{"line_number":52,"context_line":"    if _is_systemd is not None:"},{"line_number":53,"context_line":"        return _is_systemd"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"    _is_systemd \u003d False"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"    if psutil.Process(1).name() \u003d\u003d \"systemd\" or os.path.exists("},{"line_number":58,"context_line":"            SYSTEMCTL_CHECK_PATH):"},{"line_number":59,"context_line":"        # NOTE(kaisers): exit code might be \u003e1 in theory but in practice this"},{"line_number":60,"context_line":"        # is hard coded to 1. Due to backwards compatibility and systemd"},{"line_number":61,"context_line":"        # CODING_STYLE this is unlikely to change."},{"line_number":62,"context_line":"        sysdout, sysderr \u003d processutils.execute(\"systemctl\","},{"line_number":63,"context_line":"                                                \"is-system-running\","},{"line_number":64,"context_line":"                                                check_exit_code\u003d[0, 1])"},{"line_number":65,"context_line":"        for state in VALID_SYSD_STATES:"},{"line_number":66,"context_line":"            if state \u003d\u003d sysdout.strip():"},{"line_number":67,"context_line":"                _is_systemd \u003d True"},{"line_number":68,"context_line":"                break"},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"    return _is_systemd"},{"line_number":71,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"5fc1f717_852c08ad","line":68,"range":{"start_line":52,"start_character":0,"end_line":68,"end_character":21},"in_reply_to":"5fc1f717_7f396e3d","updated":"2019-04-02 12:39:16.000000000","message":"thanks, added local variable and moved assignment to global variable to the end","commit_id":"e660c6646b8f8dd02c0b64b20b6c2db630969315"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"be4e9179d6606b6e31d3ad4ce164103938c50ad0","unresolved":false,"context_lines":[{"line_number":52,"context_line":"    if _is_systemd is not None:"},{"line_number":53,"context_line":"        return _is_systemd"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"    tmp_is_systemd \u003d False"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"    if psutil.Process(1).name() \u003d\u003d \"systemd\" or os.path.exists("},{"line_number":58,"context_line":"            SYSTEMCTL_CHECK_PATH):"}],"source_content_type":"text/x-python","patch_set":4,"id":"5fc1f717_3e92fe4c","line":55,"updated":"2019-04-02 17:13:36.000000000","message":"I think this is typically done with a lock-and-recheck. Not that that\u0027s any prettier.","commit_id":"a5c26d865fd082c4aaff3635612fe841f9a7482f"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fc070cc06045be14b20f18a5cb05d4713cb9968f","unresolved":false,"context_lines":[{"line_number":45,"context_line":"_is_systemd \u003d None"},{"line_number":46,"context_line":""},{"line_number":47,"context_line":""},{"line_number":48,"context_line":"@utils.synchronized(\u0027qb_is_systemd\u0027)"},{"line_number":49,"context_line":"def is_systemd():"},{"line_number":50,"context_line":"    \"\"\"Checks if the host is running systemd\"\"\""},{"line_number":51,"context_line":"    global _is_systemd"}],"source_content_type":"text/x-python","patch_set":6,"id":"5fc1f717_dc1f4259","line":48,"updated":"2019-04-02 18:21:12.000000000","message":"Yeah, usually the pattern is:\n\n def foo():\n     global _foo\n\n     if _foo is None:\n         with lock():\n             # check again \u003croll eyes\u003e\n             if _foo is None:\n                 do_stuff_to_set__foo()\n     return _foo\n\n...so that you don\u0027t have to lock in the \"normal\" case, i.e. where _foo is already set.\n\nWhich is why I said \"Not that that\u0027s any prettier\" :)\n\nI don\u0027t know how frequently this thing is accessed, whether it\u0027s worth doing the above.","commit_id":"562862b5abe4d319e4b9ab691151b3fd46fb413a"}]}
