We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
LZ4_compress and LZ4_uncompress removed
Since commit python-lz4/python-lz4@d62fdc50c0e183d7260961f09d4e0701fbdf0c5c LZ4_compress and LZ4_decompress have been removed (they've been deprecated for a while). With the version of python-lz4 released on pypi, it means we can't use lz4 compression with dask, and worse importing dask.bytes.compression errors out.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dask/bytes/compression.py`
Content:
```
1 from __future__ import print_function, division, absolute_import
2 
3 import bz2
4 import sys
5 import zlib
6 
7 from toolz import identity
8 
9 from ..compatibility import gzip_compress, gzip_decompress, GzipFile
10 from ..utils import ignoring
11 
12 
13 def noop_file(file, **kwargs):
14     return file
15 
16 
17 compress = {'gzip': gzip_compress,
18             'zlib': zlib.compress,
19             'bz2': bz2.compress,
20             None: identity}
21 decompress = {'gzip': gzip_decompress,
22               'zlib': zlib.decompress,
23               'bz2': bz2.decompress,
24               None: identity}
25 files = {'gzip': lambda f, **kwargs: GzipFile(fileobj=f, **kwargs),
26          None: noop_file}
27 seekable_files = {None: noop_file}
28 
29 
30 with ignoring(ImportError):
31     import snappy
32     compress['snappy'] = snappy.compress
33     decompress['snappy'] = snappy.decompress
34 
35 
36 with ignoring(ImportError):
37     import lz4
38     compress['lz4'] = lz4.LZ4_compress
39     decompress['lz4'] = lz4.LZ4_uncompress
40 
41 with ignoring(ImportError):
42     from ..compatibility import LZMAFile, lzma_compress, lzma_decompress
43     compress['xz'] = lzma_compress
44     decompress['xz'] = lzma_decompress
45     files['xz'] = LZMAFile
46 
47 # Seekable xz files actually tend to scan whole file - see `get_xz_blocks`
48 # with ignoring(ImportError):
49 #     import lzma
50 #     seekable_files['xz'] = lzma.LZMAFile
51 #
52 # with ignoring(ImportError):
53 #     import lzmaffi
54 #     seekable_files['xz'] = lzmaffi.LZMAFile
55 
56 
57 if sys.version_info[0] >= 3:
58     import bz2
59     files['bz2'] = bz2.BZ2File
60 
61 
62 def get_xz_blocks(fp):
63     from lzmaffi import (STREAM_HEADER_SIZE, decode_stream_footer,
64                          decode_index, LZMAError)
65     fp.seek(0, 2)
66 
67     def _peek(f, size):
68         data = f.read(size)
69         f.seek(-size, 1)
70         return data
71 
72     if fp.tell() < 2 * STREAM_HEADER_SIZE:
73         raise LZMAError("file too small")
74 
75     # read stream paddings (4 bytes each)
76     fp.seek(-4, 1)
77     padding = 0
78     while _peek(fp, 4) == b'\x00\x00\x00\x00':
79         fp.seek(-4, 1)
80         padding += 4
81 
82     fp.seek(-STREAM_HEADER_SIZE + 4, 1)
83 
84     stream_flags = decode_stream_footer(_peek(fp, STREAM_HEADER_SIZE))
85     fp.seek(-stream_flags.backward_size, 1)
86 
87     index = decode_index(_peek(fp, stream_flags.backward_size), padding)
88     return {'offsets': [b.compressed_file_offset for i, b in index],
89             'lengths': [b.unpadded_size for i, b in index],
90             'check': stream_flags.check}
91 
92 
93 def xz_decompress(data, check):
94     from lzmaffi import decode_block_header_size, LZMADecompressor, FORMAT_BLOCK
95     hsize = decode_block_header_size(data[:1])
96     header = data[:hsize]
97     dc = LZMADecompressor(format=FORMAT_BLOCK, header=header,
98                           unpadded_size=len(data), check=check)
99     return dc.decompress(data[len(header):])
100
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dask/bytes/compression.py b/dask/bytes/compression.py
--- a/dask/bytes/compression.py
+++ b/dask/bytes/compression.py
@@ -33,10 +33,17 @@
     decompress['snappy'] = snappy.decompress
 
 
-with ignoring(ImportError):
-    import lz4
-    compress['lz4'] = lz4.LZ4_compress
-    decompress['lz4'] = lz4.LZ4_uncompress
+try:
+    import lz4.block
+    compress['lz4'] = lz4.block.compress
+    compress['lz4'] = lz4.block.decompress
+except ImportError:
+    try:
+        import lz4
+        compress['lz4'] = lz4.LZ4_compress
+        compress['lz4'] = lz4.LZ4_uncompress
+    except ImportError:
+        pass
 
 with ignoring(ImportError):
     from ..compatibility import LZMAFile, lzma_compress, lzma_decompress

{"golden_diff": "diff --git a/dask/bytes/compression.py b/dask/bytes/compression.py\n--- a/dask/bytes/compression.py\n+++ b/dask/bytes/compression.py\n@@ -33,10 +33,17 @@\n     decompress['snappy'] = snappy.decompress\n \n \n-with ignoring(ImportError):\n-    import lz4\n-    compress['lz4'] = lz4.LZ4_compress\n-    decompress['lz4'] = lz4.LZ4_uncompress\n+try:\n+    import lz4.block\n+    compress['lz4'] = lz4.block.compress\n+    compress['lz4'] = lz4.block.decompress\n+except ImportError:\n+    try:\n+        import lz4\n+        compress['lz4'] = lz4.LZ4_compress\n+        compress['lz4'] = lz4.LZ4_uncompress\n+    except ImportError:\n+        pass\n \n with ignoring(ImportError):\n     from ..compatibility import LZMAFile, lzma_compress, lzma_decompress\n", "issue": "LZ4_compress and LZ4_uncompress removed\nSince commit python-lz4/python-lz4@d62fdc50c0e183d7260961f09d4e0701fbdf0c5c LZ4_compress and LZ4_decompress have been removed (they've been deprecated for a while). With the version of python-lz4 released on pypi, it means we can't use lz4 compression with dask, and worse importing dask.bytes.compression errors out.\r\n\n", "before_files": [{"content": "from __future__ import print_function, division, absolute_import\n\nimport bz2\nimport sys\nimport zlib\n\nfrom toolz import identity\n\nfrom ..compatibility import gzip_compress, gzip_decompress, GzipFile\nfrom ..utils import ignoring\n\n\ndef noop_file(file, **kwargs):\n    return file\n\n\ncompress = {'gzip': gzip_compress,\n            'zlib': zlib.compress,\n            'bz2': bz2.compress,\n            None: identity}\ndecompress = {'gzip': gzip_decompress,\n              'zlib': zlib.decompress,\n              'bz2': bz2.decompress,\n              None: identity}\nfiles = {'gzip': lambda f, **kwargs: GzipFile(fileobj=f, **kwargs),\n         None: noop_file}\nseekable_files = {None: noop_file}\n\n\nwith ignoring(ImportError):\n    import snappy\n    compress['snappy'] = snappy.compress\n    decompress['snappy'] = snappy.decompress\n\n\nwith ignoring(ImportError):\n    import lz4\n    compress['lz4'] = lz4.LZ4_compress\n    decompress['lz4'] = lz4.LZ4_uncompress\n\nwith ignoring(ImportError):\n    from ..compatibility import LZMAFile, lzma_compress, lzma_decompress\n    compress['xz'] = lzma_compress\n    decompress['xz'] = lzma_decompress\n    files['xz'] = LZMAFile\n\n# Seekable xz files actually tend to scan whole file - see `get_xz_blocks`\n# with ignoring(ImportError):\n#     import lzma\n#     seekable_files['xz'] = lzma.LZMAFile\n#\n# with ignoring(ImportError):\n#     import lzmaffi\n#     seekable_files['xz'] = lzmaffi.LZMAFile\n\n\nif sys.version_info[0] >= 3:\n    import bz2\n    files['bz2'] = bz2.BZ2File\n\n\ndef get_xz_blocks(fp):\n    from lzmaffi import (STREAM_HEADER_SIZE, decode_stream_footer,\n                         decode_index, LZMAError)\n    fp.seek(0, 2)\n\n    def _peek(f, size):\n        data = f.read(size)\n        f.seek(-size, 1)\n        return data\n\n    if fp.tell() < 2 * STREAM_HEADER_SIZE:\n        raise LZMAError(\"file too small\")\n\n    # read stream paddings (4 bytes each)\n    fp.seek(-4, 1)\n    padding = 0\n    while _peek(fp, 4) == b'\\x00\\x00\\x00\\x00':\n        fp.seek(-4, 1)\n        padding += 4\n\n    fp.seek(-STREAM_HEADER_SIZE + 4, 1)\n\n    stream_flags = decode_stream_footer(_peek(fp, STREAM_HEADER_SIZE))\n    fp.seek(-stream_flags.backward_size, 1)\n\n    index = decode_index(_peek(fp, stream_flags.backward_size), padding)\n    return {'offsets': [b.compressed_file_offset for i, b in index],\n            'lengths': [b.unpadded_size for i, b in index],\n            'check': stream_flags.check}\n\n\ndef xz_decompress(data, check):\n    from lzmaffi import decode_block_header_size, LZMADecompressor, FORMAT_BLOCK\n    hsize = decode_block_header_size(data[:1])\n    header = data[:hsize]\n    dc = LZMADecompressor(format=FORMAT_BLOCK, header=header,\n                          unpadded_size=len(data), check=check)\n    return dc.decompress(data[len(header):])\n", "path": "dask/bytes/compression.py"}], "after_files": [{"content": "from __future__ import print_function, division, absolute_import\n\nimport bz2\nimport sys\nimport zlib\n\nfrom toolz import identity\n\nfrom ..compatibility import gzip_compress, gzip_decompress, GzipFile\nfrom ..utils import ignoring\n\n\ndef noop_file(file, **kwargs):\n    return file\n\n\ncompress = {'gzip': gzip_compress,\n            'zlib': zlib.compress,\n            'bz2': bz2.compress,\n            None: identity}\ndecompress = {'gzip': gzip_decompress,\n              'zlib': zlib.decompress,\n              'bz2': bz2.decompress,\n              None: identity}\nfiles = {'gzip': lambda f, **kwargs: GzipFile(fileobj=f, **kwargs),\n         None: noop_file}\nseekable_files = {None: noop_file}\n\n\nwith ignoring(ImportError):\n    import snappy\n    compress['snappy'] = snappy.compress\n    decompress['snappy'] = snappy.decompress\n\n\ntry:\n    import lz4.block\n    compress['lz4'] = lz4.block.compress\n    compress['lz4'] = lz4.block.decompress\nexcept ImportError:\n    try:\n        import lz4\n        compress['lz4'] = lz4.LZ4_compress\n        compress['lz4'] = lz4.LZ4_uncompress\n    except ImportError:\n        pass\n\nwith ignoring(ImportError):\n    from ..compatibility import LZMAFile, lzma_compress, lzma_decompress\n    compress['xz'] = lzma_compress\n    decompress['xz'] = lzma_decompress\n    files['xz'] = LZMAFile\n\n# Seekable xz files actually tend to scan whole file - see `get_xz_blocks`\n# with ignoring(ImportError):\n#     import lzma\n#     seekable_files['xz'] = lzma.LZMAFile\n#\n# with ignoring(ImportError):\n#     import lzmaffi\n#     seekable_files['xz'] = lzmaffi.LZMAFile\n\n\nif sys.version_info[0] >= 3:\n    import bz2\n    files['bz2'] = bz2.BZ2File\n\n\ndef get_xz_blocks(fp):\n    from lzmaffi import (STREAM_HEADER_SIZE, decode_stream_footer,\n                         decode_index, LZMAError)\n    fp.seek(0, 2)\n\n    def _peek(f, size):\n        data = f.read(size)\n        f.seek(-size, 1)\n        return data\n\n    if fp.tell() < 2 * STREAM_HEADER_SIZE:\n        raise LZMAError(\"file too small\")\n\n    # read stream paddings (4 bytes each)\n    fp.seek(-4, 1)\n    padding = 0\n    while _peek(fp, 4) == b'\\x00\\x00\\x00\\x00':\n        fp.seek(-4, 1)\n        padding += 4\n\n    fp.seek(-STREAM_HEADER_SIZE + 4, 1)\n\n    stream_flags = decode_stream_footer(_peek(fp, STREAM_HEADER_SIZE))\n    fp.seek(-stream_flags.backward_size, 1)\n\n    index = decode_index(_peek(fp, stream_flags.backward_size), padding)\n    return {'offsets': [b.compressed_file_offset for i, b in index],\n            'lengths': [b.unpadded_size for i, b in index],\n            'check': stream_flags.check}\n\n\ndef xz_decompress(data, check):\n    from lzmaffi import decode_block_header_size, LZMADecompressor, FORMAT_BLOCK\n    hsize = decode_block_header_size(data[:1])\n    header = data[:hsize]\n    dc = LZMADecompressor(format=FORMAT_BLOCK, header=header,\n                          unpadded_size=len(data), check=check)\n    return dc.decompress(data[len(header):])\n", "path": "dask/bytes/compression.py"}]}