We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[requires.io] dependency update on master branch


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `warehouse/celery.py`
Content:
```
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12 
13 import celery.backends
14 
15 # We need to trick Celery into supporting rediss:// URLs which is how redis-py
16 # signals that you should use Redis with TLS.
17 celery.backends.BACKEND_ALIASES["rediss"] = "warehouse.celery:TLSRedisBackend"  # noqa
18 
19 from celery import Celery, Task
20 from celery.backends.redis import RedisBackend as _RedisBackend
21 from celery.signals import celeryd_init
22 from pyramid import scripting
23 from pyramid.threadlocal import get_current_request
24 from raven.contrib.celery import register_signal, register_logger_signal
25 
26 from warehouse.config import Environment, configure
27 
28 
29 @celeryd_init.connect
30 def _configure_celery(*args, **kwargs):
31     config = configure()
32     register_logger_signal(config.registry["raven.client"])
33     register_signal(config.registry["raven.client"])
34 
35 
36 class TLSRedisBackend(_RedisBackend):
37 
38     def _params_from_url(self, url, defaults):
39         params = super()._params_from_url(url, defaults)
40         params.update({"connection_class": self.redis.SSLConnection})
41         return params
42 
43 
44 class WarehouseTask(Task):
45 
46     abstract = True
47 
48     def __call__(self, *args, **kwargs):
49         registry = self.app.pyramid_config.registry
50         pyramid_env = scripting.prepare(registry=registry)
51 
52         try:
53             return super().__call__(pyramid_env["request"], *args, **kwargs)
54         finally:
55             pyramid_env["closer"]()
56 
57     def apply_async(self, *args, **kwargs):
58         # The API design of Celery makes this threadlocal pretty impossible to
59         # avoid :(
60         request = get_current_request()
61 
62         # If for whatever reason we were unable to get a request we'll just
63         # skip this and call the original method to send this immediately.
64         if request is None or not hasattr(request, "tm"):
65             return super().apply_async(*args, **kwargs)
66 
67         # This will break things that expect to get an AsyncResult because
68         # we're no longer going to be returning an async result from this when
69         # called from within a request, response cycle. Ideally we shouldn't be
70         # waiting for responses in a request/response cycle anyways though.
71         request.tm.get().addAfterCommitHook(
72             self._after_commit_hook,
73             args=args,
74             kws=kwargs,
75         )
76 
77     def _after_commit_hook(self, success, *args, **kwargs):
78         if success:
79             super().apply_async(*args, **kwargs)
80 
81 
82 app = Celery("warehouse")
83 app.Task = WarehouseTask
84 
85 
86 task = app.task
87 
88 
89 def includeme(config):
90     s = config.registry.settings
91     app.pyramid_config = config
92     app.conf.update(
93         BROKER_URL=s["celery.broker_url"],
94         BROKER_USE_SSL=s["warehouse.env"] == Environment.production,
95         CELERY_DISABLE_RATE_LIMITS=True,
96         CELERY_RESULT_BACKEND=s["celery.result_url"],
97         CELERY_RESULT_SERIALIZER="json",
98         CELERY_TASK_SERIALIZER="json",
99         CELERY_ACCEPT_CONTENT=["json", "msgpack"],
100         CELERY_MESSAGE_COMPRESSION="gzip",
101         CELERY_QUEUE_HA_POLICY="all",
102     )
103
```
--- 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/warehouse/celery.py b/warehouse/celery.py
--- a/warehouse/celery.py
+++ b/warehouse/celery.py
@@ -10,11 +10,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import celery.backends
+import celery.app.backends
 
 # We need to trick Celery into supporting rediss:// URLs which is how redis-py
 # signals that you should use Redis with TLS.
-celery.backends.BACKEND_ALIASES["rediss"] = "warehouse.celery:TLSRedisBackend"  # noqa
+celery.app.backends.BACKEND_ALIASES["rediss"] = "warehouse.celery:TLSRedisBackend"  # noqa
 
 from celery import Celery, Task
 from celery.backends.redis import RedisBackend as _RedisBackend

{"golden_diff": "diff --git a/warehouse/celery.py b/warehouse/celery.py\n--- a/warehouse/celery.py\n+++ b/warehouse/celery.py\n@@ -10,11 +10,11 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n-import celery.backends\n+import celery.app.backends\n \n # We need to trick Celery into supporting rediss:// URLs which is how redis-py\n # signals that you should use Redis with TLS.\n-celery.backends.BACKEND_ALIASES[\"rediss\"] = \"warehouse.celery:TLSRedisBackend\"  # noqa\n+celery.app.backends.BACKEND_ALIASES[\"rediss\"] = \"warehouse.celery:TLSRedisBackend\"  # noqa\n \n from celery import Celery, Task\n from celery.backends.redis import RedisBackend as _RedisBackend\n", "issue": "[requires.io] dependency update on master branch\n\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport celery.backends\n\n# We need to trick Celery into supporting rediss:// URLs which is how redis-py\n# signals that you should use Redis with TLS.\ncelery.backends.BACKEND_ALIASES[\"rediss\"] = \"warehouse.celery:TLSRedisBackend\"  # noqa\n\nfrom celery import Celery, Task\nfrom celery.backends.redis import RedisBackend as _RedisBackend\nfrom celery.signals import celeryd_init\nfrom pyramid import scripting\nfrom pyramid.threadlocal import get_current_request\nfrom raven.contrib.celery import register_signal, register_logger_signal\n\nfrom warehouse.config import Environment, configure\n\n\n@celeryd_init.connect\ndef _configure_celery(*args, **kwargs):\n    config = configure()\n    register_logger_signal(config.registry[\"raven.client\"])\n    register_signal(config.registry[\"raven.client\"])\n\n\nclass TLSRedisBackend(_RedisBackend):\n\n    def _params_from_url(self, url, defaults):\n        params = super()._params_from_url(url, defaults)\n        params.update({\"connection_class\": self.redis.SSLConnection})\n        return params\n\n\nclass WarehouseTask(Task):\n\n    abstract = True\n\n    def __call__(self, *args, **kwargs):\n        registry = self.app.pyramid_config.registry\n        pyramid_env = scripting.prepare(registry=registry)\n\n        try:\n            return super().__call__(pyramid_env[\"request\"], *args, **kwargs)\n        finally:\n            pyramid_env[\"closer\"]()\n\n    def apply_async(self, *args, **kwargs):\n        # The API design of Celery makes this threadlocal pretty impossible to\n        # avoid :(\n        request = get_current_request()\n\n        # If for whatever reason we were unable to get a request we'll just\n        # skip this and call the original method to send this immediately.\n        if request is None or not hasattr(request, \"tm\"):\n            return super().apply_async(*args, **kwargs)\n\n        # This will break things that expect to get an AsyncResult because\n        # we're no longer going to be returning an async result from this when\n        # called from within a request, response cycle. Ideally we shouldn't be\n        # waiting for responses in a request/response cycle anyways though.\n        request.tm.get().addAfterCommitHook(\n            self._after_commit_hook,\n            args=args,\n            kws=kwargs,\n        )\n\n    def _after_commit_hook(self, success, *args, **kwargs):\n        if success:\n            super().apply_async(*args, **kwargs)\n\n\napp = Celery(\"warehouse\")\napp.Task = WarehouseTask\n\n\ntask = app.task\n\n\ndef includeme(config):\n    s = config.registry.settings\n    app.pyramid_config = config\n    app.conf.update(\n        BROKER_URL=s[\"celery.broker_url\"],\n        BROKER_USE_SSL=s[\"warehouse.env\"] == Environment.production,\n        CELERY_DISABLE_RATE_LIMITS=True,\n        CELERY_RESULT_BACKEND=s[\"celery.result_url\"],\n        CELERY_RESULT_SERIALIZER=\"json\",\n        CELERY_TASK_SERIALIZER=\"json\",\n        CELERY_ACCEPT_CONTENT=[\"json\", \"msgpack\"],\n        CELERY_MESSAGE_COMPRESSION=\"gzip\",\n        CELERY_QUEUE_HA_POLICY=\"all\",\n    )\n", "path": "warehouse/celery.py"}], "after_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport celery.app.backends\n\n# We need to trick Celery into supporting rediss:// URLs which is how redis-py\n# signals that you should use Redis with TLS.\ncelery.app.backends.BACKEND_ALIASES[\"rediss\"] = \"warehouse.celery:TLSRedisBackend\"  # noqa\n\nfrom celery import Celery, Task\nfrom celery.backends.redis import RedisBackend as _RedisBackend\nfrom celery.signals import celeryd_init\nfrom pyramid import scripting\nfrom pyramid.threadlocal import get_current_request\nfrom raven.contrib.celery import register_signal, register_logger_signal\n\nfrom warehouse.config import Environment, configure\n\n\n@celeryd_init.connect\ndef _configure_celery(*args, **kwargs):\n    config = configure()\n    register_logger_signal(config.registry[\"raven.client\"])\n    register_signal(config.registry[\"raven.client\"])\n\n\nclass TLSRedisBackend(_RedisBackend):\n\n    def _params_from_url(self, url, defaults):\n        params = super()._params_from_url(url, defaults)\n        params.update({\"connection_class\": self.redis.SSLConnection})\n        return params\n\n\nclass WarehouseTask(Task):\n\n    abstract = True\n\n    def __call__(self, *args, **kwargs):\n        registry = self.app.pyramid_config.registry\n        pyramid_env = scripting.prepare(registry=registry)\n\n        try:\n            return super().__call__(pyramid_env[\"request\"], *args, **kwargs)\n        finally:\n            pyramid_env[\"closer\"]()\n\n    def apply_async(self, *args, **kwargs):\n        # The API design of Celery makes this threadlocal pretty impossible to\n        # avoid :(\n        request = get_current_request()\n\n        # If for whatever reason we were unable to get a request we'll just\n        # skip this and call the original method to send this immediately.\n        if request is None or not hasattr(request, \"tm\"):\n            return super().apply_async(*args, **kwargs)\n\n        # This will break things that expect to get an AsyncResult because\n        # we're no longer going to be returning an async result from this when\n        # called from within a request, response cycle. Ideally we shouldn't be\n        # waiting for responses in a request/response cycle anyways though.\n        request.tm.get().addAfterCommitHook(\n            self._after_commit_hook,\n            args=args,\n            kws=kwargs,\n        )\n\n    def _after_commit_hook(self, success, *args, **kwargs):\n        if success:\n            super().apply_async(*args, **kwargs)\n\n\napp = Celery(\"warehouse\")\napp.Task = WarehouseTask\n\n\ntask = app.task\n\n\ndef includeme(config):\n    s = config.registry.settings\n    app.pyramid_config = config\n    app.conf.update(\n        BROKER_URL=s[\"celery.broker_url\"],\n        BROKER_USE_SSL=s[\"warehouse.env\"] == Environment.production,\n        CELERY_DISABLE_RATE_LIMITS=True,\n        CELERY_RESULT_BACKEND=s[\"celery.result_url\"],\n        CELERY_RESULT_SERIALIZER=\"json\",\n        CELERY_TASK_SERIALIZER=\"json\",\n        CELERY_ACCEPT_CONTENT=[\"json\", \"msgpack\"],\n        CELERY_MESSAGE_COMPRESSION=\"gzip\",\n        CELERY_QUEUE_HA_POLICY=\"all\",\n    )\n", "path": "warehouse/celery.py"}]}