diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 65e25fa..4889dd7 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [3.7, 3.8, 3.9, "3.10"] + python: [3.7, 3.8, 3.9, "3.10", "3.11"] steps: - uses: actions/checkout@v3 @@ -24,4 +24,4 @@ jobs: run: tox -e py - name: Run flake8 / docs run: tox -e flake8,docs - if: "matrix.python == '3.10'" + if: "matrix.python == '3.10' || matrix.python == '3.11'" diff --git a/panoramisk/actions.py b/panoramisk/actions.py index 1b5ed5e..b5d7b9c 100644 --- a/panoramisk/actions.py +++ b/panoramisk/actions.py @@ -92,6 +92,8 @@ def completed(self): return True elif resp.subevent in ('End', 'Exec'): return True + elif resp.event in ('AsyncAGIExec',): + return True elif resp.response in ('Success', 'Error', 'Fail', 'Failure'): return True elif not self.multi: diff --git a/panoramisk/call_manager.py b/panoramisk/call_manager.py index 037d984..36755c3 100644 --- a/panoramisk/call_manager.py +++ b/panoramisk/call_manager.py @@ -45,7 +45,7 @@ def set_result(self, future, result): def send_originate(self, action): action['Async'] = 'true' action = actions.Action(action) - future = asyncio.Future() + future = self.loop.create_future() self.send_action(action).add_done_callback( partial(self.set_result, future)) return future diff --git a/panoramisk/command.py b/panoramisk/command.py index 71426a5..e188381 100644 --- a/panoramisk/command.py +++ b/panoramisk/command.py @@ -47,7 +47,7 @@ def done(future): def show(f=None): if f: print(f.result()) - f = asyncio.Task(result.queue.get()) + f = asyncio.create_task(result.queue.get()) f.add_done_callback(show) show() diff --git a/panoramisk/fast_agi.py b/panoramisk/fast_agi.py index ce50ce0..f634b5e 100644 --- a/panoramisk/fast_agi.py +++ b/panoramisk/fast_agi.py @@ -79,9 +79,12 @@ class Application(dict): buf_size = 100 - def __init__(self, default_encoding='utf-8', loop=None, raise_on_error=False): + def __init__( + self, default_encoding='utf-8', loop=None, raise_on_error=False, decode_errors='strict' + ): super(Application, self).__init__() self.default_encoding = default_encoding + self.decode_errors = decode_errors if loop is None: try: loop = asyncio.get_running_loop() @@ -162,7 +165,7 @@ async def start(request): buffer = b'' while b'\n\n' not in buffer: buffer += await reader.read(self.buf_size) - lines = buffer[:-2].decode(self.default_encoding).split('\n') + lines = buffer[:-2].decode(self.default_encoding, errors=self.decode_errors).split('\n') headers = OrderedDict([ line.split(': ', 1) for line in lines if ': ' in line ]) diff --git a/panoramisk/manager.py b/panoramisk/manager.py index 29e12ce..881aebe 100644 --- a/panoramisk/manager.py +++ b/panoramisk/manager.py @@ -194,12 +194,12 @@ def connect(self, run_forever=False, on_startup=None, on_shutdown=None): """connect to the server""" if self.loop is None: # pragma: no cover self.loop = asyncio.get_event_loop() - t = asyncio.Task( + t = asyncio.create_task( self.loop.create_connection( self.config['protocol_factory'], self.config['host'], self.config['port'], ssl=self.config['ssl']), - loop=self.loop) + ) t.add_done_callback(self.connection_made) if run_forever: diff --git a/panoramisk/testing.py b/panoramisk/testing.py index 3899289..557ab3d 100644 --- a/panoramisk/testing.py +++ b/panoramisk/testing.py @@ -53,7 +53,7 @@ def __init__(self, **config): protocol = AMIProtocol() protocol.factory = manager protocol.connection_made(mock.MagicMock()) - future = asyncio.Future() + future = self.loop.create_future() future.set_result((mock.MagicMock(), protocol)) self.protocol = protocol self.connection_made(future) diff --git a/tests/test_manager_with_fixtures.py b/tests/test_manager_with_fixtures.py index 470b33c..1997edf 100644 --- a/tests/test_manager_with_fixtures.py +++ b/tests/test_manager_with_fixtures.py @@ -106,10 +106,10 @@ def test_close(manager): def test_events(manager): - future = asyncio.Future() - manager = manager() + future = manager.loop.create_future() + @manager.register_event('Peer*') def callback(manager, event): future.set_result(event)