)]}'
{"swift/common/utils.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":3302,"context_line":"    \"\"\""},{"line_number":3303,"context_line":"    global _libc_sendfile"},{"line_number":3304,"context_line":"    if _libc_sendfile is None and not system_has_sendfile():"},{"line_number":3305,"context_line":"        raise Exception(\"Unable to use sendfile.\")"},{"line_number":3306,"context_line":"    ret \u003d _libc_sendfile(out_fd, in_fd, ctypes.c_uint64(offset), count)"},{"line_number":3307,"context_line":"    if ret \u003c 0:"},{"line_number":3308,"context_line":"        err \u003d ctypes.get_errno()"}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_85a6c251","line":3305,"updated":"2014-10-03 01:46:41.000000000","message":"You could create, find or use a less generic Exception to throw.","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"}],"swift/obj/diskfile.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":539,"context_line":"                with open(\u0027/proc/sys/fs/pipe-max-size\u0027) as f:"},{"line_number":540,"context_line":"                    max_pipe_size \u003d int(f.read())"},{"line_number":541,"context_line":"                self.pipe_size \u003d min(max_pipe_size, self.disk_chunk_size)"},{"line_number":542,"context_line":"        elif config_true_value(conf.get(\u0027sendfile\u0027, \u0027no\u0027)):"},{"line_number":543,"context_line":"            if system_has_sendfile():"},{"line_number":544,"context_line":"                self.send_mode \u003d SEND_MODE_SENDFILE"},{"line_number":545,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_2596f64c","line":542,"updated":"2014-10-03 01:46:41.000000000","message":"config_true_value sees None as False, so you don\u0027t need to define a default of \u0027no\u0027.\n\n  config_true_value(conf.get(\u0027sendfile\u0027))","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":880,"context_line":"    :param device_path: on-disk device path, used when quarantining an obj"},{"line_number":881,"context_line":"    :param logger: logger caller wants this object to use"},{"line_number":882,"context_line":"    :param quarantine_hook: 1-arg callable called w/reason when quarantined"},{"line_number":883,"context_line":"    :param send_mode: if true, use zero-copy splice() to send data"},{"line_number":884,"context_line":"    :param pipe_size: size of pipe buffer used in zero-copy operations"},{"line_number":885,"context_line":"    :param keep_cache: should resulting reads be kept in the buffer cache"},{"line_number":886,"context_line":"    \"\"\""}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_257d161d","line":883,"updated":"2014-10-03 01:46:41.000000000","message":"Update this comment as send_mode is not a boolean anymore.","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":898,"context_line":"        self._device_path \u003d device_path"},{"line_number":899,"context_line":"        self._logger \u003d logger"},{"line_number":900,"context_line":"        self._quarantine_hook \u003d quarantine_hook"},{"line_number":901,"context_line":"        self._send_mode \u003d send_mode"},{"line_number":902,"context_line":"        self._pipe_size \u003d pipe_size"},{"line_number":903,"context_line":"        if keep_cache:"},{"line_number":904,"context_line":"            # Caller suggests we keep this in cache, only do it if the"}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_e5ff8e65","line":901,"updated":"2014-10-03 01:46:41.000000000","message":"Seeing as send mode isn\u0027t a simple binary anymore but instead an int (with 0 - 2 meaning something) there probably should be a sanity check. Maybe define the variables initially like:\n\n  SEND_MODES \u003d (\n      SEND_MODE_NORMAL,\n      SEND_MODE_SPLICE,\n      SEND_MODE_SENDFILE,\n  ) \u003d (\n      0,\n      1,\n      2,\n  )\n\nThen you can sanitise with a:\n\n  self._send_mode \u003d send_mode if send_mode in SEND_MODES \\\n      else SEND_MODE_NORMAL","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":1187,"context_line":"    :param obj: object name for the object"},{"line_number":1188,"context_line":"    :param _datadir: override the full datadir otherwise constructed here"},{"line_number":1189,"context_line":"    :param policy_idx: used to get the data dir when constructing it here"},{"line_number":1190,"context_line":"    :param send_mode: if true, use zero-copy splice() to send data"},{"line_number":1191,"context_line":"    :param pipe_size: size of pipe buffer used in zero-copy operations"},{"line_number":1192,"context_line":"    \"\"\""},{"line_number":1193,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_45f4da86","line":1190,"updated":"2014-10-03 01:46:41.000000000","message":"Update the comment here too.","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"}],"test/unit/obj/test_diskfile.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"4d0e2ad3d97c6e837edb891ade6f52e98e87b93c","unresolved":false,"context_lines":[{"line_number":2254,"context_line":"                        lambda *args, **kwargs: None):"},{"line_number":2255,"context_line":"            with mock.patch(\u0027swift.obj.diskfile.sendfile\u0027, mock_sendfile):"},{"line_number":2256,"context_line":"                with mock.patch(\u0027swift.obj.diskfile.system_has_sendfile\u0027,"},{"line_number":2257,"context_line":"                                lambda: True):"},{"line_number":2258,"context_line":"                    df \u003d self._get_open_disk_file(fsize\u003d128)"},{"line_number":2259,"context_line":"                    df.reader().zero_copy_send(77)"},{"line_number":2260,"context_line":"                    self.assertEqual(sendfile_args[0], 77)"}],"source_content_type":"text/x-python","patch_set":3,"id":"baa201ad_65e63eb6","line":2257,"updated":"2014-10-03 01:46:41.000000000","message":"Instead of using lambda\u0027s you could let mock do it:\n\n  @mock.patch(\u0027swift.obj.diskfile.system_has_sendfile\u0027, return_value\u003dTrue)\n  @mock.patch(\u0027swift.obj.diskfile.trampoline\u0027, return_value\u003dNone)\n  def test_sendfile_send(self, mock_tramp, mock_has_sendfile):\n\nAnd you\u0027ll remove 2 lambda\u0027s and 2 levels of with\u0027ing.\n\nYou could look at doing similar things on the last test file as well. Noting you can use side_effect rather then return_value if you need the mock object to raise an exception.","commit_id":"b6aa18f69e941ec2889b550ee2a9b4f8d272ec8f"}]}
