From: Stefano Rivera <stefano@rivera.za.net>
Date: Fri, 25 Mar 2022 11:06:05 -0400
Subject: Python 3.10 support

Python 3.10 dropped support for the loop parameter to asyncio.sleep()
and gather(), the default loop is used instead. I haven't audited
whether any of these code paths now need to use set_default_loop(), but
tests pass, so... LGTM?

Support for using the default loop was only added in 3.7, so this drops
support for Python 3.6.

https://bugs.python.org/issue42392

Bug-Upstream: https://github.com/loads/molotov/issues/137
Bug-Debian: https://bugs.debian.org/1001423
Forwarded: https://github.com/loads/molotov/pull/141
---
 molotov/runner.py       | 2 +-
 molotov/tests/statsd.py | 4 ++--
 molotov/util.py         | 2 +-
 setup.py                | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/molotov/runner.py b/molotov/runner.py
index 0b3471a..8ad4fb5 100644
--- a/molotov/runner.py
+++ b/molotov/runner.py
@@ -54,7 +54,7 @@ class Runner(object):
         return future.result()
 
     def gather(self, *futures):
-        return asyncio.gather(*futures, loop=self.loop, return_exceptions=True)
+        return asyncio.gather(*futures, return_exceptions=True)
 
     def ensure_future(self, coro):
         return asyncio.ensure_future(coro, loop=self.loop)
diff --git a/molotov/tests/statsd.py b/molotov/tests/statsd.py
index 0806d47..a149825 100644
--- a/molotov/tests/statsd.py
+++ b/molotov/tests/statsd.py
@@ -33,7 +33,7 @@ class UDPServer(object):
             self.loop = loop
         self._stop = asyncio.Future(loop=self.loop)
         self._done = asyncio.Future(loop=self.loop)
-        self.incoming = asyncio.Queue(loop=self.loop)
+        self.incoming = asyncio.Queue()
 
     async def run(self):
         ctx = {}
@@ -51,7 +51,7 @@ class UDPServer(object):
             await self._stop
             ctx["proto"].disconnect()
 
-        await asyncio.gather(conn, listen_for_stop(), loop=self.loop)
+        await asyncio.gather(conn, listen_for_stop())
         self._done.set_result(True)
 
     def flush(self):
diff --git a/molotov/util.py b/molotov/util.py
index e2a2b20..c58d45c 100644
--- a/molotov/util.py
+++ b/molotov/util.py
@@ -255,7 +255,7 @@ def get_var(name, factory=None):
 # taken from https://stackoverflow.com/a/37211337
 def _make_sleep():
     async def sleep(delay, result=None, *, loop=None):
-        coro = asyncio.sleep(delay, result=result, loop=loop)
+        coro = asyncio.sleep(delay, result=result)
         task = asyncio.ensure_future(coro, loop=loop)
         sleep.tasks.add(task)
         try:
diff --git a/setup.py b/setup.py
index ea5fc18..298d499 100644
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,8 @@
 import sys
 from setuptools import setup, find_packages
 
-if sys.version_info < (3, 6):
-    raise ValueError("Requires Python 3.6 or superior")
+if sys.version_info < (3, 7):
+    raise ValueError("Requires Python 3.7 or superior")
 
 from molotov import __version__  # NOQA
 
