Skip to content

Commit

Permalink
Change tactic so we don't break APNS pushkins
Browse files Browse the repository at this point in the history
  • Loading branch information
devonh committed Feb 4, 2025
1 parent e595785 commit ad4088d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion sygnal/gcmpushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,14 @@ async def create(
# set the usual env var and use `trust_env=True`
os.environ["HTTPS_PROXY"] = proxy_url

# Ensure the asyncio reactor has started the event loop.
loop = asyncio.get_event_loop()

# ClientSession must be instantiated by an async function, hence we do this
# here instead of `__init__`.
session = aiohttp.ClientSession(trust_env=True, auto_decompress=False)
session = aiohttp.ClientSession(
trust_env=True, auto_decompress=False, loop=loop
)

cls.google_auth_request = google.auth.transport._aiohttp_requests.Request(
session=session
Expand Down
7 changes: 2 additions & 5 deletions sygnal/sygnal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
import copy
import importlib
import logging
Expand All @@ -29,7 +28,7 @@
from opentracing import Tracer
from opentracing.scope_managers.asyncio import AsyncioScopeManager
from twisted.internet import asyncioreactor, defer
from twisted.internet.defer import Deferred
from twisted.internet.defer import Deferred, ensureDeferred
from twisted.internet.interfaces import (
IReactorCore,
IReactorFDSet,
Expand Down Expand Up @@ -226,9 +225,7 @@ def run(self) -> None:
@defer.inlineCallbacks
def start() -> Generator[Deferred[Any], Any, Any]:
try:
yield Deferred.fromFuture(
asyncio.ensure_future(self.make_pushkins_then_start())
)
yield ensureDeferred(self.make_pushkins_then_start())
except Exception:
# Print the exception and bail out.
print("Error during startup:", file=sys.stderr)
Expand Down

0 comments on commit ad4088d

Please sign in to comment.