Skip to content

Commit

Permalink
Merge pull request #113 from romkazor/master
Browse files Browse the repository at this point in the history
Fix and updates
  • Loading branch information
gawel authored Mar 10, 2023
2 parents 47a40db + e38e013 commit 7c35a7e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'"
2 changes: 2 additions & 0 deletions panoramisk/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion panoramisk/call_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion panoramisk/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 5 additions & 2 deletions panoramisk/fast_agi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
])
Expand Down
4 changes: 2 additions & 2 deletions panoramisk/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion panoramisk/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_manager_with_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7c35a7e

Please sign in to comment.